sys.exit() signal.signal(signal.SIGINT, sigint_handler) reconnect_attempts = 0 while not honbot.is_quitting: time.sleep(1) # Cooling.. client.login() while client.is_logged_in and not honbot.is_quitting: if client.is_connected is True: # Reset the number of attempts. reconnect_attempts = 0 # Do some stuff if I want time.sleep(1) else: reconnect_attempts += 1 log.info("Disconnected from chat server") log.info("Reconnecting in 30 seconds (Attempts %d of 5)" % reconnect_attempts) time.sleep(30) try: client.connect() except ChatServerError, e: log.error(e) if __name__ == "__main__": log.add_logger(sys.stdout, 'DEBUG', False) log.add_logger('honbot.log', 'DEBUG', False) main()
delete = args.delete ytvbot_dir = setup_config_dir(ytvbot_dir) config = None with codecs.open(os.path.join(ytvbot_dir, "config.yml"), 'r', "utf-8") as stream: config = yaml.load(stream) while True: for a in config['accounts']: process_recordings( a['email'], a['password'], ytvbot_dir, output_dir, progress_bar=progress_bar, search=search, network=network, json_file=args.links, delete=delete, ) sleep_time = 60 * int(args.sleep) logger.info("Checking again in %i minutes." % args.sleep) time.sleep(sleep_time) logger = add_logger("ytvbot") if __name__ == "__main__": main()
# Temporary client config # Move to self implementation using QSettings later. client._configure(protocol=19) app = QApplication(sys.argv) app.setApplicationName("HoNChatPy") #app.setQuitOnLastWindowClosed(True) # May need to change for system tray behaviour login_window = HCPLoginWindow(client) login_window.setObjectName('login_window') core_window = HCPCoreWindow(client) core_window.setObjectName('hcp_window') while True: while not client.is_logged_in: login_window.show() app.exec_() while client.is_logged_in: core_window.show() client.connect() app.exec_() if __name__ == "__main__": log.add_logger(sys.stdout, 'DEBUG', False) log.add_logger('honchat_log', 'DEBUG', True) main()
log.debug("Client disconnected, cooling..") time.sleep(2) else: # Start dropping the players online to zero once it's been determined that # the servers are down. if down_count > 5: db.execute("""INSERT INTO players (time, value) VALUES (%s, %s)""", [str(int(time.time())), 0]) time.sleep(90) # Loop increment test_count += 1 # And log back out again hon_monitor.logged_in = False def sigint_handler(signal, frame): """ Basic SIGINT quit """ log.info("Quitting...") sys.exit(0) if __name__ == "__main__": # Set up some global stuff. signal.signal(signal.SIGINT, sigint_handler) log.add_logger('/var/python/HoNStatus/honstatus_mon.log', 'ERROR', False) pname = "hon_monitor:%s:%s" % (uname()[1], getpid()) setproctitle(pname) print "HoN Monitor started" main() print "HoN Monitor stopped"