def main(argv): try: opts, _ = getopt.getopt(argv, "p:", ["port"]) except getopt.GetoptError: sys.exit(1) global HTTP_PORT global devices global configurations global log_db global general_responses for opt, arg in opts: if opt in ("-p", "--port"): try: HTTP_PORT = int(arg) except ValueError: raise ValueError sys.exit(1) ticker = Ticker() try: logging.basicConfig(filename=LOG_FILE, \ level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %I:%M:%S %p') log_db = SqliteHelper() load_general_responses() server = MyServer(('', HTTP_PORT), RequestHandler) ticker.start() print "Http server stated at %d" % HTTP_PORT server.serve_forever() except KeyboardInterrupt: print '^C received, shutting down server' ticker.stop() server.socket.close()
def selectChannel(name): global ticker import uwebsockets.client as uwc lcd.clear() lcd.text(lcd.CENTER, 40, 'joining') lcd.text(lcd.CENTER, 60, 'chat') lcd.font(lcd.FONT_UNICODE) if tcfg['tickers']: ticker = Ticker([''] * 9, 0xffffff, rotation=0, sliding=False, speed=16, delay=10, x=2, multiline=True) exitChat = False with uwc.connect('wss://irc-ws.chat.twitch.tv') as ws: ws.send('NICK justinfan123') #ws.send('CAP REQ :twitch.tv/tags') ws.send('JOIN #' + name) msg = ws.recv() i = 0 while msg.find('/NAMES') == -1: msg = ws.recv() msg = ws.recv() while not exitChat: if msg != '': #gc.collect() parseChatMsg(msg) msg = ws.recv() while btnB.isPressed(): exitChat = True if tcfg['tickers']: ticker.stop() del ticker return mainMenu
processes = set_val(processes, args[1]) elif args[0] == "rollback": util.assert_arg_len(args, 2) processes = rollback(processes, args[1]) elif args[0] == "add": util.assert_arg_len(args, 2) processes = add_process(processes, args[1]) elif args[0] == "remove": util.assert_arg_len(args, 2) processes = remove_process(processes, args[1]) elif args[0] == "time-failure": util.assert_arg_len(args, 3) processes = time_fail(processes, args[1], args[2]) elif args[0] == "arbitrary-failure": util.assert_arg_len(args, 3) processes = arbitrary_fail(processes, args[1], args[2]) else: print('Unsupported command') ticker.upd_list(processes) for p in processes: p.history_print() except KeyboardInterrupt: print("Please, do not use Ctrl+C. Try again with \'exit\' command") # debug except Exception as e: print("Please try again") ticker.stop()