def run(self): args = self.parse_args() if args is None: return while True: self.print_session_params(args) if not args.no_speed_check: print("Checking your Internet speed to adjust the script speed, please wait for a minute...") print("(use " + COLOR_BOLD + "--no-speed-check" + COLOR_ENDC + " to skip this check)") sleeper.update_random_sleep_range() device_wrapper, app_version = self.get_device_wrapper(args) if device_wrapper is None: return self.set_session_args(args) action_runner = self.actions_mgr.select_action_runner(args) if action_runner is None: return action_runner.set_params(args) self.limits_mgr.set_limits(args) try: self.start_session(args, device_wrapper, app_version) migrate_from_json_to_sql(self.session_state.my_username) self.storage = Storage(self.session_state.my_username, args) action_runner.run(device_wrapper, self.storage, self.session_state, self.on_action_callback, self.limits_mgr.is_limit_reached_for_action) except (KeyboardInterrupt, UserSwitchFailedException, DatabaseMigrationFailedException): self.end_session(device_wrapper) return except ActionBlockedError as ex: print_timeless("") print_timeless(COLOR_FAIL + str(ex) + COLOR_ENDC) self.end_session(device_wrapper) return except Exception as ex: if __version__.__debug_mode__: raise ex else: print_timeless(COLOR_FAIL + f"\nCaught an exception:\n{ex}" + COLOR_ENDC) print(COLOR_FAIL + traceback.format_exc() + COLOR_ENDC) save_crash(device_wrapper.get(), ex) self.end_session(device_wrapper) if self.repeat is not None: if not self.repeat_session(args): break else: break
def run(self): args = self.parse_args() if args is None: return while True: self.print_session_params(args) self.update_session_speed(args) device_wrapper, app_version = self.get_device_wrapper(args) if device_wrapper is None: return self.set_session_args(args) action_runner = self.actions_mgr.select_action_runner(args) if action_runner is None: return action_runner.reset_params() action_runner.set_params(args) self.limits_mgr.set_limits(args) try: self.prepare_session_state(args, device_wrapper, app_version, save_profile_info=True) migrate_from_json_to_sql(self.session_state.my_username) migrate_from_sql_to_peewee(self.session_state.my_username) self.storage = InsomniacStorage(self.session_state.my_username, args) self.session_state.set_storage_layer(self.storage) self.session_state.start_session() action_runner.run(device_wrapper, self.storage, self.session_state, self.on_action_callback, self.limits_mgr.is_limit_reached_for_action) except (KeyboardInterrupt, UserSwitchFailedException, DatabaseMigrationFailedException): self.end_session(device_wrapper) return except (ActionBlockedError, HardBanError) as ex: if type(ex) is ActionBlockedError: self.storage.log_softban() if type(ex) is HardBanError and args.app_name is not None: InsomniacStorage.log_hardban(args.app_name) print_timeless("") print(COLOR_FAIL + describe_exception(ex, with_stacktrace=False) + COLOR_ENDC) save_crash(device_wrapper.get()) if self.next_config_file is None: self.end_session(device_wrapper) return except Exception as ex: if __version__.__debug_mode__: raise ex else: print(COLOR_FAIL + describe_exception(ex) + COLOR_ENDC) save_crash(device_wrapper.get(), ex) self.end_session( device_wrapper, with_app_closing=self.should_close_app_after_session( args, device_wrapper)) if self.repeat is not None: if not self.repeat_session(args): break else: break