""" import time from posttroll.message import Message from dc.connections import DCConnectionsPush class Messager(object): """Dummy messager class. """ def __init__(self): self.count = 0 def __call__(self): self.count += 1 return Message('/test/1/2/3', 'info', "what's up doc #%d" % self.count) if __name__ == '__main__': CONNECTIONS = DCConnectionsPush().start() MSG = Messager() while True: try: CONNECTIONS.send(MSG()) time.sleep(1) except (KeyboardInterrupt, SystemExit): print "quitting ..." CONNECTIONS.stop() break
# pytroll. If not, see <http://www.gnu.org/licenses/>. """A simple producer. """ import time from posttroll.message import Message from dc.connections import DCConnectionsPush class Messager(object): """Dummy messager class. """ def __init__(self): self.count = 0 def __call__(self): self.count += 1 return Message('/test/1/2/3', 'info', "what's up doc #%d"%self.count) if __name__ == '__main__': CONNECTIONS = DCConnectionsPush().start() MSG = Messager() while True: try: CONNECTIONS.send(MSG()) time.sleep(1) except (KeyboardInterrupt, SystemExit): print "quitting ..." CONNECTIONS.stop() break
for fil in younger_than_stamp_files(): base = os.path.basename(fil) metadata = { "filename": base, "URIs": ["file://"+fil], "type": "HRPT 1b", "format": "EPS 1b", "time_of_first_scanline": datetime.strptime(base[16:30], "%Y%m%d%H%M%S").isoformat(), "time_of_last_scanline": datetime.strptime(base[32:46], "%Y%m%d%H%M%S").isoformat()} import pprint pprint.pprint(metadata) yield Message('/dc/polar/gds', 'update', metadata) if __name__ == '__main__': CONNECTIONS = DCConnectionsPush().start() # wait to get a connection time.sleep(3) while True: try: #send_new_files() for i in send_new_files(): CONNECTIONS.send(i) time.sleep(60) except (KeyboardInterrupt, SystemExit): print "quitting ..." CONNECTIONS.stop() break