def run(): try: bot.run() except NeedUserInteraction as exception: alert(str(exception)) try: if raw_input(I18n.get('token_resolved')).strip() == 'y': run() except NameError as e: if input(I18n.get('token_resolved')).strip() == 'y': run()
def run(): try: bot.run() except NeedUserInteraction as exception: alert(exception.message) if raw_input(I18n.get('token_resolved')) == 'y': run()
def __init__(self, pretix_cache: PretixCache): super().__init__(intents=discord.Intents( members=True, messages=True, reactions=True)) self._pretix_cache = pretix_cache self._database = Database() self._i18n = I18n(self._database)
def create_app(env): # Set up the app app = Flask('FlaskStarter') app.config.update(Config["all"]) if env == "test": app.config.update(Config[env]) else: app.config.update(Config["dev"]) # Set up DB db = Database(app) # Set up i18n i18n = I18n(app) # Set current locale for jinja access @app.before_request def before_request(): app.jinja_env.globals['current_locale'] = list_locale() # Add index route @app.route('/') def display_index(): return render_template('index.html') # List supported languages @app.route('/i18n', methods=['GET']) def get_i18n(): if request.method == 'GET': return jsonify(list_locales()) # Handle exceptions @app.errorhandler(WebException) def handle_web_exception(error): response = jsonify(error.to_dict()) response.status_code = error.status_code return response # Import controllers from src.controllers.auth import auth app.register_blueprint(auth.bp) from src.controllers import account app.register_blueprint(account.bp) return app
return None def alert(message = ''): print(('\a' * 5) + message) def main(): args = parse_args() proxy = setup_proxy(args.proxy_url, args.proxy_auth) image = Image(args.file, args.round_sensitive, args.image_brightness) bot = Bot(image, args.fingerprint, args.start_x, args.start_y, args.mode_defensive, args.colors_ignored, proxy, args.draw_strategy) bot.init() def run(): try: bot.run() except NeedUserInteraction as exception: alert(exception.message) if raw_input(I18n.get('token_resolved')) == 'y': run() run() if __name__ == '__main__': try: main() except KeyboardInterrupt: print(I18n.get('Bye'))
def parse_args(): parser = ArgumentParser() parser.add_argument('-i', '--image', required=True, dest='file', help=I18n.get('--image', 'true')) parser.add_argument('-f', '--fingerprint', required=True, dest='fingerprint', help=I18n.get('--fingerprint', 'true')) parser.add_argument('-x', '--start_x', required=True, type=int, dest='start_x', help=I18n.get('--start_x', 'true')) parser.add_argument('-y', '--start_y', required=True, type=int, dest='start_y', help=I18n.get('--start_y', 'true')) parser.add_argument('--colors_ignored', required=False, type=int, default=[], nargs='+', dest='colors_ignored', help=I18n.get('--colors_ignored', 'true')) parser.add_argument('--colors_not_overwrite', required=False, type=int, default=[], nargs='+', dest='colors_not_overwrite', help=I18n.get('--colors_not_overwrite', 'true')) parser.add_argument('--draw_strategy', required=False, default='randomize', dest='draw_strategy', help=I18n.get('--draw_strategy', 'true')) parser.add_argument('--mode_defensive', required=False, default=True, dest='mode_defensive', help=I18n.get('--mode_defensive', 'true')) parser.add_argument('--proxy_url', required=False, dest='proxy_url', help=I18n.get('--proxy_url', 'true')) parser.add_argument('--proxy_auth', required=False, dest='proxy_auth', help=I18n.get('--proxy_auth', 'true')) parser.add_argument('--round_sensitive', required=False, type=int, default=3, dest='round_sensitive', help=I18n.get('--round_sensitive', 'true')) parser.add_argument('--image_brightness', required=False, type=int, default=15, dest='image_brightness', help=I18n.get('--image_brightness', 'true')) parser.add_argument('--detect_area_min_range', required=False, type=int, default=-5000, dest='min_range', help=I18n.get('--detect_area_min_range', 'true')) parser.add_argument('--detect_area_max_range', required=False, type=int, default=5000, dest='max_range', help=I18n.get('--detect_area_max_range', 'true')) parser.add_argument('--QR_text', required=False, default="", dest='QR_text', help=I18n.get('--QR_text', 'true')) parser.add_argument('--QR_scale', required=False, type=int, default=3, dest='QR_scale', help=I18n.get('--QR_scale', 'true')) parser.add_argument('--xreversed', required=False, default=False, dest='xreversed', help=I18n.get('--xreversed', 'true')) parser.add_argument('--yreversed', required=False, default=False, dest='yreversed', help=I18n.get('--yreversed', 'true')) return parser.parse_args()
def parse_args(): def str2bool(v): if isinstance(v, bool): return v if v.lower() in ('yes', 'true', 't', 'y', '1'): return True elif v.lower() in ('no', 'false', 'f', 'n', '0'): return False else: raise argparse.ArgumentTypeError('Boolean value expected.') parser = argparse.ArgumentParser() parser.add_argument('-i', '--image', required=True, dest='file', help=I18n.get('--image', 'true')) parser.add_argument('-f', '--fingerprint', required=False, dest='fingerprint', help=I18n.get('--fingerprint', 'true')) parser.add_argument('-x', '--start_x', required=False, type=int, dest='start_x', help=I18n.get('--start_x', 'true')) parser.add_argument('-y', '--start_y', required=False, type=int, dest='start_y', help=I18n.get('--start_y', 'true')) parser.add_argument("--stealth", type=str2bool, nargs='?', const=True, default=False, help=I18n.get('--stealth', 'true')) parser.add_argument('--colors_ignored', required=False, type=int, default=[], nargs='+', dest='colors_ignored', help=I18n.get('--colors_ignored', 'true')) parser.add_argument('--colors_not_overwrite', required=False, type=int, default=[], nargs='+', dest='colors_not_overwrite', help=I18n.get('--colors_not_overwrite', 'true')) parser.add_argument('--draw_strategy', required=False, default='randomize', dest='draw_strategy', help=I18n.get('--draw_strategy', 'true')) parser.add_argument('--mode_defensive', required=False, default=True, dest='mode_defensive', help=I18n.get('--mode_defensive', 'true')) parser.add_argument('--proxy_url', required=False, dest='proxy_url', help=I18n.get('--proxy_url', 'true')) parser.add_argument('--proxy_auth', required=False, dest='proxy_auth', help=I18n.get('--proxy_auth', 'true')) parser.add_argument('--round_sensitive', required=False, type=int, default=3, dest='round_sensitive', help=I18n.get('--round_sensitive', 'true')) parser.add_argument('--image_brightness', required=False, type=int, default=15, dest='image_brightness', help=I18n.get('--image_brightness', 'true')) parser.add_argument('--detect_area_min_range', required=False, type=int, default=-5000, dest='min_range', help=I18n.get('--detect_area_min_range', 'true')) parser.add_argument('--detect_area_max_range', required=False, type=int, default=5000, dest='max_range', help=I18n.get('--detect_area_max_range', 'true')) parser.add_argument('--QR_text', required=False, default="", dest='QR_text', help=I18n.get('--QR_text', 'true')) parser.add_argument('--QR_scale', required=False, type=int, default=3, dest='QR_scale', help=I18n.get('--QR_scale', 'true')) parser.add_argument('--xreversed', required=False, default=False, dest='xreversed', help=I18n.get('--xreversed', 'true')) parser.add_argument('--yreversed', required=False, default=False, dest='yreversed', help=I18n.get('--yreversed', 'true')) parsed_args = parser.parse_args() if parsed_args.fingerprint is None: parsed_args.fingerprint = ''.join( choice(string.ascii_lowercase + string.digits) for _ in range(32)) if parsed_args.start_x is None or parsed_args.start_y is None: name = ntpath.splitext(ntpath.basename(parsed_args.file))[0] arr = name.split('_') if len(arr) != 3: parser.print_usage() print('Error: ' + I18n.get('no-coords', 'true')) sys.exit(1) parsed_args.start_x = int(arr[1]) parsed_args.start_y = int(arr[2]) return parsed_args
bot = Bot(image, args.fingerprint, args.start_x, args.start_y, args.stealth, args.mode_defensive, args.colors_ignored, args.colors_not_overwrite, args.min_range, args.max_range, proxy, args.draw_strategy, args.xreversed, args.yreversed) bot.init() def run(): try: bot.run() except NeedUserInteraction as exception: alert(str(exception)) try: if raw_input(I18n.get('token_resolved')).strip() == 'y': run() except NameError as e: if input(I18n.get('token_resolved')).strip() == 'y': run() run() if __name__ == '__main__': c = 5 while c: try: main() except KeyboardInterrupt: print(I18n.get('Erro')) pass