def main(): # parse args parser = get_parser() args = parser.parse_args(sys.argv[1:2]) command = args.command if command: handle_command(command, parser)
def main(): if len(sys.argv) < 2: handle_command("help", None) else: git = Git() if not git.check_for_git(): git.install_git() handle_command(git, sys.argv[1], sys.argv[2:])
def run_bot(): if slack_client.rtm_connect(with_team_state=False): print("ProntoBot is online!") prontobot_id = slack_client.api_call("auth.test")["user_id"] while prontobot_id: command, channel, user_id = find_bot_commands( slack_client.rtm_read(), prontobot_id) if command: handle_command(slack_client, command, channel, user_id) time.sleep(RTM_READ_DELAY) else: print("Connection failed. Exception traceback printed above.")
def commands(): # print(request.form) # Validate the token token = request.form.get("token") if token != VERIFICATION_TOKEN: abort(401) # Delegate command to handlers return handle_command(client, request)
def on_command(self, command, parameters): result = commands.handle_command(self, command, parameters) if result == False: parameters = ['***'] * len(parameters) log_message = '<%s> /%s %s' % (self.name, command, ' '.join(parameters)) if result: log_message += ' -> %s' % result self.send_chat(result) print log_message.encode('ascii', 'replace')
def main(): s = socket.socket() s.settimeout(0.5) s.connect((cfg.HOST, cfg.PORT)) s.send(f'PASS {cfg.PASS}\r\n'.encode('utf-8')) s.send(f'NICK {cfg.NICK}\r\n'.encode('utf-8')) s.send(f'JOIN {cfg.CHAN}\r\n'.encode('utf-8')) chat(s, 'bot is alive') pts = UpdatePoints() pts.daemon = True pts.start() chitter = ChatThread(s) chitter.daemon = True chitter.start() def signal_handler(signal, frame): """Shuts down the UpdateThread and closes socket.""" pts.event.set() chitter.event.set() close_dbs() chat(s, 'killing bot') s.shutdown(socket.SHUT_RDWR) s.close() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) while True: try: response = s.recv(1024).decode('utf-8') if response == 'PING :tmi.twitch.tv\r\n': s.send('PONG :tmi.twitch.tv\r\n'.encode('utf-8')) else: commands.handle_command(s, response) except socket.timeout: continue except Exception: chat(s, 'bot ded') raise
def run(): while True: input_line = sys.stdin.readline() if not input_line: sys.exit(0) try: input_obj = json.loads(input_line) except ValueError: results.write_error_result(code = results.INVALID_JSON) continue #get the id of the input line try: input_id = input_obj['id'] except KeyError: results.write_error_result(code = results.NO_ID_FOUND) continue except TypeError: results.write_error_result(code = results.NO_DICT_FOUND) continue try: with sync_db.error.convert(): commands.handle_command(input_id, input_obj) except sync_db.error.SyncError as error: results.write_error_result(result_id = input_id, code = results.SYNC_ERROR, oracle_code = error.code, oracle_message = "{0}".format(error)) except sync_db.error.Error as error: results.write_error_result(result_id = input_id, code = results.DATABASE_ERROR, oracle_code = error.code, oracle_message = "{0}".format(error))
def give_help(self, msg): '''special handling for help messages''' if config.help_regex.match(msg): return commands.handle_command(self, 'help') else: return False
def command(self, msg): return commands.handle_command(self, msg)
# exchange = trade.set_auth_info(exchange) # trade.print_wallet(exchange.fetch_balance()) exit = False print() print("-" * 70) print() print("Welcome to the Red Sun\n") print("-" * 70) print() commands.start_app() while (exit == False): print("$", end=" ") inputText = input() flag = commands.handle_command(inputText) if (flag == "exit"): exit = True functions.disable_console() continue
if not cmd: return try: mt = os.path.getmtime(commands.__file__) except Exception, e: print 'Exception %s checking command module' % repr(e) return if mt != self.commandsmt: try: reload(commands) except Exception, e: print 'Exception %s reloading command module' % repr(e) return self.commandsmt = mt try: commands.handle_command(self, e, cmd, args) except Exception, e: print 'Exception %s handling command' % repr(e) if __name__ == "__main__": bot = ChanBot( channel='#london-hack-space-dev', nickname='hackbot', server='irc.freenode.org', ) bot.start()
@app.route("/robots.txt") def robots(): return send_from_directory(os.path.join(app.root_path, "static"), "robots.txt", mimetype="text/plain") @app.route("/keybase.txt") def keybase(): return send_from_directory(os.path.join(app.root_path, "static"), "keybase.txt", mimetype="text/plain") @freezer.register_generator def page(): for p in live_pages: yield {"path": p.path} if __name__ == "__main__": if len(sys.argv) > 1: if sys.argv[1] == "build": import subprocess subprocess.call("bundle exec compass compile --app-dir static/ -c static/config.rb --force", shell=True) DEBUG = False freezer.freeze() else: handle_command(sys.argv[1:]) # handle creating new photos here else: app.run(port=9090, debug=DEBUG)
experimental_setup.ExperimentDef = definitions.experiment_definition( experimental_setup) experimental_setup.update_paths() experimental_setup.AlgorithmRunParameters = algrun_parameters.create_algrun_parameters( experimental_setup) # The experiment defines many algorithm configurations, in the field # experimental_setup.AlgorithmRunParameters. If only a subset should be # acted upon at the moment, an `algrun_tag` can be specified on the CLI, # which causes the experiment to ignore all algorithm configurations that # have not been marked with the specified `algrun_tag`. if arguments.algrun_tag is not None: experimental_setup.filter_algruns_by_tag(arguments.algrun_tag) # By default, the experiment will preload the saved AD-tree, required by # algorithm configurations that require it (tagged with `adtree`), # although this only happens if there are such configurations selected for # running, after filtering by `algrun_tag`. should_preload_adtree = \ arguments.object == 'exp' \ and arguments.verb == 'run' \ and arguments.preload_adtrees if should_preload_adtree is True: experimental_setup.preload_ADTrees() # Handle the (object, verb) command in the arguments command_handled = util.handle_command(arguments, experimental_setup) if command_handled is False: commands.handle_command(arguments, experimental_setup)