Пример #1
0
    def run(self):
        self.progressed("Logging into oagd.net...")
        if not app.settings["device_id"]:
            app.settings["device_id"] = str(uuid4())
        try:
            result = self.client.auth(self.username, self.password,
                                      app.settings["device_id"],
                                      get_device_name())
        except UnauthorizedError:
            raise Task.Failure("Wrong e-mail address or password")

        app.settings["database_username"] = result["username"]
        app.settings["database_email"] = result["email"]
        app.settings["database_auth"] = result["auth_token"]
        app.settings["database_password"] = ""
Пример #2
0
    def run(self):
        self.progressed("Logging into openretro.org...")
        if not Settings.instance()["device_id"]:
            Settings.instance()["device_id"] = str(uuid4())
        try:
            result = self.client.authorize(
                self.username,
                self.password,
                Settings.instance()["device_id"],
                get_device_name(),
            )
        except UnauthorizedError:
            raise Task.Failure("Wrong e-mail address or password")

        Settings.instance()["database_username"] = result["username"]
        Settings.instance()["database_email"] = result["email"]
        Settings.instance()["database_auth"] = result["auth_token"]
        Settings.instance()["database_password"] = ""
Пример #3
0
    def upload_check(self, prefix):
        self.progressed(
            gettext("Finding files eligible for OpenRetro Locker") +
            " ({:0.0%})".format((prefix / 16.0)))
        file_database = FileDatabase.instance()
        cursor = file_database.cursor()
        # FIXME: prefix
        p = "0123456789ABCDEF"[prefix]
        cursor.execute(
            "SELECT DISTINCT sha1 FROM file "
            "WHERE hex(sha1) LIKE ?",
            (p + "%", ),
        )
        string_io = StringIO()
        for row in cursor:
            string_io.write(row[0])
        # print(prefix, len(string_io.getvalue()))
        self.stop_check()

        retry_seconds = 1
        while True:
            try:
                result = self.client.post("/api/locker-upload-check",
                                          data=string_io.getvalue())
            except OGDClient.ForbiddenError:
                raise Task.Failure(
                    gettext("OpenRetro Locker is not enabled for your user. "
                            "It may be available only to a few select beta "
                            "users."))
            except OGDClient.NonRetryableHTTPError as e:
                raise e
            except Exception:
                traceback.print_exc()
                self.progressed(
                    gettext("Re-trying in {0} seconds...").format(
                        retry_seconds))
                for _ in range(retry_seconds):
                    self.stop_check()
                    time.sleep(1.0)
                retry_seconds = min(retry_seconds * 2, 60 * 10)
            else:
                return result