Changeset 52:8d45fe507fa4 in stamper
- Timestamp:
- Nov 8, 2014, 1:58:59 AM (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stamper/stamper.py
r43 r52 9 9 import pygal 10 10 11 from http import HTTPClient 12 11 13 12 14 STAMPS_FILE = os.path.expanduser('~/.workstamps.json') … … 17 19 HOURS_DAY = 8 18 20 SECS_DAY = HOURS_DAY * 60 * 60 21 REMOTE_BASE_URL = 'https://localhost' 22 REMOTE_PUSH_URL = '/stamper/listen/' # IMPORTANT: keep the trailing / 23 REMOTE_USER = None 24 REMOTE_PASSWORD = None 19 25 20 26 … … 427 433 print('[warning] ' + str(len(stamps)) + ' stamps merged') 428 434 print('[warning] remember to review the resulting stamps file') 435 436 def push_stamps(self, customer=None, filter_from=None, filter_to=None): 437 stamps = [] 438 for stamp in self.stamps: 439 if stamp['customer']: 440 if customer and customer != stamp['customer']: 441 continue 442 start = datetime.strptime(stamp['start'], DATETIME_FORMAT) 443 start_day = start.strftime('%Y-%m-%d') 444 end = datetime.strptime(stamp['end'], DATETIME_FORMAT) 445 if filter_from and start < filter_from: 446 # if there is a filter setting a starting date for the 447 # report and the current stamp is from an earlier date, do 448 # not add it to the totals 449 continue 450 if filter_to and start > filter_to: 451 # similar for the end date 452 continue 453 stamps.append(stamp) 454 stamps = json.dumps(stamps, indent=4) 455 http_client = HTTPClient(REMOTE_BASE_URL, REMOTE_USER, REMOTE_PASSWORD) 456 http_client.post(REMOTE_PUSH_URL, {'stamps': stamps})
Note:
See TracChangeset
for help on using the changeset viewer.