def playback(): web.load() reader = LogReader(RsyncLogFile("wiki-beta::pharos/log", "log")) # skip the log till the latest entry in the database timestamp = web.query('SELECT last_modified FROM thing ORDER BY last_modified DESC LIMIT 1')[0].last_modified reader.skip_till(timestamp) playback = LogPlayback(Infobase()) while True: for entry in reader: print reader.logfile.tell(), entry.timestamp playback.playback(entry) time.sleep(60)
def logstream_incr(rsync_source, **delta): if not delta: delta = dict(hours=12) # default # r = LogReader(RsyncLogFile('ia331526::pharos_0/code/openlibrary/pharos/booklog', 'log')) r = LogReader(RsyncLogFile(rsync_source, 'log')) d = date.today()-timedelta(**delta) print d r.skip_till(datetime(d.year, d.month, d.day)) while True: for x in r: if type(x) == tuple and x[0]=='error': print ('error', ctime(), x) else: yield x print "hit end of rsync stream, reloading", ctime() sleep (30)
def playback(): web.load() reader = LogReader(RsyncLogFile("wiki-beta::pharos/log", "log")) # skip the log till the latest entry in the database timestamp = web.query( 'SELECT last_modified FROM thing ORDER BY last_modified DESC LIMIT 1' )[0].last_modified reader.skip_till(timestamp) playback = LogPlayback(Infobase()) while True: for entry in reader: print reader.logfile.tell(), entry.timestamp playback.playback(entry) time.sleep(60)