zephyr_mirror: Only resend old messages when invoked with --resend-log

(imported from commit e5a7c8d5b920d796ebbf68efc2beca6b14036695)
This commit is contained in:
Keegan McAllister 2012-09-07 13:17:56 -04:00
parent 028bb9aa8d
commit 1c64ce8bfc
1 changed files with 10 additions and 9 deletions

View File

@ -53,15 +53,16 @@ if __name__ == '__main__':
for sub in subs_list: for sub in subs_list:
subs.add((sub, '*', '*')) subs.add((sub, '*', '*'))
try: if sys.argv[1:] == ['--resend-log']:
with open('zephyrs', 'r') as log: try:
for ln in log: with open('zephyrs', 'r') as log:
zeph = simplejson.loads(ln) for ln in log:
print "sending saved message to %s from %s..." % (zeph['class'], zeph['sender']) zeph = simplejson.loads(ln)
send_zephyr(zeph) print "sending saved message to %s from %s..." % (zeph['class'], zeph['sender'])
except: send_zephyr(zeph)
print >>sys.stderr, 'Could not load zephyr log' except:
traceback.print_exc() print >>sys.stderr, 'Could not load zephyr log'
traceback.print_exc()
with open('zephyrs', 'a') as log: with open('zephyrs', 'a') as log:
print "Starting receive loop" print "Starting receive loop"