Ejemplo n.º 1
0
    def login(self):
        """
        Open up login dialog or log out depending on logged status.
        """
        if self.logged:
            QApplication.setOverrideCursor(Qt.WaitCursor)
            self.api.client_logout()
            self.api.client_remove_token()
            self.logged = False
            self.sig_logged_out.emit()
            self.tracker.track_event('authenticate',
                                     'logout',
                                     label=self.username)
        else:
            dlg = AuthenticationDialog(self.api, parent=self)

            if self.tracker:
                self.tracker.track_page('/login', pagetitle='Login dialog')

            if dlg.exec_():
                self.api.client_store_token(dlg.token)
                self.username = dlg.username
                self.logged = True
                self.sig_logged_in.emit()

                if self.tracker:
                    self.tracker.track_event('authenticate',
                                             'login',
                                             label=self.username)
            self._track_tab()

        self.update_login_status()
        logger.debug(str((self.logged, self.username)))
Ejemplo n.º 2
0
def botlogin(qtbot, tmpconfig):
    tmpconfig.set('main', 'anaconda_api_url', 'https://api.anaconda.org/')
    widget = AuthenticationDialog(api=AnacondaAPI())
    widget.config = tmpconfig  # Patch with a temporal config file
    widget.setup()
    qtbot.addWidget(widget)
    widget.show()
    return qtbot, widget