def tail_logfiles(logs, milestones, interval=60): db = loaddb.connect_db() loaddb.init_listeners(db) cursor = db.cursor() loaddb.support_mysql57(cursor) loaddb.set_active_cursor(cursor) elapsed_time = 0 master = loaddb.create_master_reader() try: while True: try: interval_work(cursor, interval, master) if not interval: break loaddb.run_timers(cursor, elapsed_time) except IOError, e: error("IOError: %s" % e) time.sleep(interval) elapsed_time += interval if crawl_utils.taildb_stop_requested(): info("Exit due to taildb stop request.") break finally: loaddb.set_active_cursor(None) cursor.close() loaddb.cleanup_listeners(db) db.close()
def tail_logfiles(logs, milestones, interval=60): db = loaddb.connect_db() loaddb.init_listeners(db) cursor = db.cursor() loaddb.support_mysql57(cursor) loaddb.set_active_cursor(cursor) elapsed_time = 0 master = loaddb.create_master_reader() try: while True: try: interval_work(cursor, interval, master) if not interval: break loaddb.run_timers(cursor, elapsed_time) except IOError as e: error("IOError: %s" % e) time.sleep(interval) elapsed_time += interval if crawl_utils.taildb_stop_requested(): info("Exit due to taildb stop request.") break finally: loaddb.set_active_cursor(None) cursor.close() loaddb.cleanup_listeners(db) db.close() info("Bye!")
def team_pages(c): info("Updating teams page") render(c, 'teams') for captain in query.get_team_captains(c): team_page(c, captain) def player_page(c, player): info("Updating player page for %s" % player) render(c, 'player', dest = ('%s/%s' % (crawl_utils.PLAYER_BASE, player.lower())), pars = { 'player' : player }) # Update tourney overview every 5 mins. INTERVAL = crawl_utils.UPDATE_INTERVAL TIMER = [ loaddb.define_timer( INTERVAL, tourney_overview ), loaddb.define_timer( INTERVAL, team_pages ), loaddb.define_timer( INTERVAL, player_pages ) ] LISTENER = [ loaddb.define_cleanup(tourney_overview), loaddb.define_cleanup(team_pages), loaddb.define_cleanup(player_pages) ] if __name__ == '__main__': db = loaddb.connect_db() try: for l in LISTENER: l.cleanup(db) finally: db.close()
#! /usr/bin/env python import loaddb import update_page db = loaddb.connect_db() c = db.cursor() loaddb.support_mysql57(c) try: update_page.index_page(c) finally: db.close()
#! /usr/bin/env python import loaddb import update_page print("Hello from update_index") args = loaddb.load_args() print("Connecting to database") db = loaddb.connect_db(host=args.db_host, password=args.db_pass, retry=args.db_retry_connect) c = db.cursor() loaddb.support_mysql57(c) print("Building index page") try: update_page.index_page(c) finally: db.close() print("All done")