def from_tmp_que(params, channel): create_que(params, channel) bind(params, channel) from_existing_que(params, channel) purge(params, channel) delete(params, channel) args_parser = create_parser() cmd_line_arguments = args_parser.parse_args(sys.argv[1:]) if cmd_line_arguments.command not in ["from_existing_que", "from_tmp_que"]: args_parser.print_help() exit() rmq_connection = rmq_tools.rmq_connect(cmd_line_arguments.rabbit_address) rmq_channel = rmq_connection.channel() if cmd_line_arguments.count: lim = int(cmd_line_arguments.count) else: lim = 0 all_cnt = 0 if cmd_line_arguments.command == "from_existing_que": from_existing_que(cmd_line_arguments, rmq_channel) elif cmd_line_arguments.command == "from_tmp_que": from_tmp_que(cmd_line_arguments, rmq_channel) else: print(
return except Exception: rmq_tools.console_log("Ошибка:\n", traceback.format_exc()) rmq_tools.console_log("Ошибка публикации сообщения!") args_parser = create_parser() rmq_params = args_parser.parse_args(sys.argv[1:]) if rmq_params.command not in ["from_console", "from_file", "batch_sending"]: args_parser.print_help() exit() if rmq_params.command == "batch_sending": batch_sending(rmq_params) else: rmq_connection = rmq_tools.rmq_connect(rmq_params.rabbit_address) rmq_channel = rmq_connection.channel() if rmq_params.command == "from_console": from_console(rmq_params, rmq_channel) elif rmq_params.command == "from_file": from_file(rmq_params, rmq_channel) else: print( "Выбранная команда ничего не делает... Используйте -h для вызова справки" ) rmq_tools.rmq_disconnect(rmq_connection)