Esempio n. 1
0
 def update_session_speed(args):
     if args.speed is not None:
         sleeper.set_random_sleep_range(int(args.speed))
     elif 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()
Esempio n. 2
0
    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
Esempio n. 3
0
    def run(self):
        args, device_wrapper, app_version = self.parse_args_and_get_device_wrapper(
        )
        if args is None or device_wrapper is None:
            return

        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()

        while True:
            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)
                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 ActionBlockedError as ex:
                print_timeless("")
                print_timeless(COLOR_FAIL + str(ex) + COLOR_ENDC)
                self.end_session(device_wrapper)
                return
            except Exception as ex:
                if __debug_mode__:
                    raise ex
                else:
                    print_timeless(COLOR_FAIL +
                                   f"\nCaught an exception:\n{ex}" +
                                   COLOR_ENDC)
                    save_crash(device_wrapper.get(), ex)

            self.end_session(device_wrapper)
            if self.repeat is not None:
                self.repeat_session(args)
            else:
                break

        print_full_report(self.sessions)
        self.sessions.persist(directory=self.session_state.my_username)