def on_login_activated(self):
        email = self.username_field.get_text().strip()
        password = self.password_field.get_text().strip()
        if not email or not password:
            return
        self.username_field.set_enabled(False)
        self.password_field.set_enabled(False)
        self.login_button.set_enabled(False)

        task = OGDClient().login_task(email, password)
        # task.progressed.connect(self.progress)
        task.succeeded.connect(self.on_success)
        # task.failed.connect(fsui.error_function(gettext("Login Failed")))
        task.failed.connect(self.on_failure)
        task.start()
Example #2
0
 def __logout_activated(self):
     auth_token = app.settings["database_auth"]
     if auth_token:
         task = OGDClient().logout_task(auth_token)
         # task.progressed.connect(self.progress)
         task.succeeded.connect(self.close)
         # task.failed.connect(fsui.error_function(gettext("Login Failed")))
         task.failed.connect(self.on_failure)
         task.start()
     else:
         # this is not a normal case, no auth token stored, but clear
         # all auth-related settings just in case
         app.settings["database_auth"] = ""
         app.settings["database_username"] = ""
         # app.settings["database_email"] = ""
         app.settings["database_password"] = ""
         self.on_close()
    def addEventListener(self, eventName, listener):
        if eventName == "destroy":
            self.destroyed.connect(listener)

        # def onLogoutActivated(self):
        #     self.setRunning(True)
        #     authToken = app.settings["database_auth"]

        #     def onResult(result):
        #         print(result)
        #         self.setRunning(False)

        #     def onError(error):
        #         print(error)

        #     def onProgress(progress):
        #         print(progress)
        #         self.errorLabel.set_text(progress.value)

        #     self.addEventListener(
        #         "destroy",
        #         AsyncTaskRunner(onResult, onError, onProgress)
        #         .run(LogoutTask(authToken))
        #         .cancel,
        #     )

        # with AsyncTaskRunner(onResult, onError, onProgress):
        #     LogoutTask(authToken)

        # import time
        # time.sleep(3)
        # self.close()

        # LogoutTask(authToken).start()
        # LogoutTask(authToken).runAsync()

        # AsyncTaskRunner(onResult, onError, onProgress).run(
        #     LogoutTask(authToken)
        # ).cancelOn(self.destroy)

        # self.runTask(LogoutTask(authToken), onProgress, onError, onComplete)

        # self.disposable = (
        #     logoutTask(auth_token)
        #     .pipe(
        #         # rx.operators.subscribe_on(rx.scheduler.EventLoopScheduler()),
        #         rx.operators.subscribe_on(rx.scheduler.NewThreadScheduler()),
        #         rx.operators.observe_on(MainLoopScheduler()),
        #     )
        #     .subscribe(self.onNext, self.onError, self.onCompleted)
        # )
        # #  ).subscribe(self, scheduler=qtScheduler)

        return
        if auth_token:
            task = OGDClient().logout_task(auth_token)
            # task.progressed.connect(self.progress)
            task.succeeded.connect(self.close)
            # task.failed.connect(fsui.error_function(gettext("Login Failed")))
            task.failed.connect(self.on_failure)
            task.start()
        else:
            # this is not a normal case, no auth token stored, but clear
            # all auth-related settings just in case
            app.settings["database_auth"] = ""
            app.settings["database_username"] = ""
            # app.settings["database_email"] = ""
            app.settings["database_password"] = ""
            self.on_close()