Changeset 60:ec70c7dc68b6 in stamper
- Timestamp:
- Dec 28, 2014, 12:57:07 PM (10 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
etc/stamper.conf
r58 r60 18 18 base_url = http://localhost:8000 19 19 login_path = /stamper/login/ 20 listen_path = /stamper/listen/21 20 user = CHANGEME 22 21 password = SECRET -
stamper/stamper.py
r59 r60 454 454 stamps = json.dumps(stamps, indent=4) 455 455 http_client = HTTPClient(self.collector['base_url']) 456 http_client.post(self.collector['login_path'], 457 {'username': self.collector['user'], 458 'password': self.collector['password']}) 459 http_client.post(self.collector['listen_path'], {'stamps': stamps}) 456 response = http_client.post(self.collector['login_path'], 457 {'username': self.collector['user'], 458 'password': self.collector['password']}) 459 # response is a json-encoded list of end-points from the collector api 460 try: 461 api = json.loads(response) 462 except ValueError: 463 print('[error] No valid api end points can be retrieved') 464 return 465 466 response = http_client.post(api['push'], {'stamps': stamps}) 467 468 # response is a json-encoded dict, containing lists of added, updated 469 # and deleted stamps (on the other side) 470 try: 471 results = json.loads(response) 472 except ValueError: 473 print('[error] stamps pushed, can not retrieve results information') 474 return 475 476 # display information 477 for k in results.keys(): 478 print('%(stamps)d stamps %(action)s' % {'stamps': len(results[k]), 479 'action': k})
Note:
See TracChangeset
for help on using the changeset viewer.