Ejemplo n.º 1
0
    def login(self):
        """
        Attempt to log in.
        Note: this method does nothing if we are already logged in.
        """
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)

        # Do we really need to login?
        if self.is_logged():
            self.logger.debug('already logged in')
            return

        self.is_logging = True
        # Are we on the good page?
        if not self.is_on_page(LoginPage):
            self.logger.debug('going to login page')
            BaseBrowser.home(self)
        self.logger.debug('attempting to log in')
        self.page.login(self.username, self.password)
        self.is_logging = False

        if not self.is_logged():
            raise BrowserIncorrectPassword()

        self.addheaders = [['User-agent', self.USER_AGENTS['desktop_firefox']]]
Ejemplo n.º 2
0
    def login(self):
        """
        Attempt to log in.
        Note: this method does nothing if we are already logged in.
        """
        assert isinstance(self.username, basestring)
        assert isinstance(self.password, basestring)

        # Do we really need to login?
        if self.is_logged():
            self.logger.debug('already logged in')
            return

        self.is_logging = True
        # Are we on the good page?
        if not self.is_on_page(LoginPage):
            self.logger.debug('going to login page')
            BaseBrowser.home(self)
        self.logger.debug('attempting to log in')
        self.page.login(self.username, self.password)
        self.is_logging = False

        if not self.is_logged():
            raise BrowserIncorrectPassword()

        self.addheaders = [
                ['User-agent', self.USER_AGENTS['desktop_firefox']]
            ]
Ejemplo n.º 3
0
    def home(self):
        """
        Ensure we are both logged and on the accounts list.
        """
        self.logger.debug('accounts list page required')
        if self.is_on_page(AccountsList) and self.page.is_accounts_list():
            self.logger.debug('already on accounts list')
            return

        # simply go to http(s)://the.doma.in/
        BaseBrowser.home(self)

        if self.is_on_page(LoginPage):
            if not self.is_logged():
                # So, we are not logged on the login page -- what about logging ourselves?
                self.login()
                # we assume we are logged in
            # for some regions, we may stay on the login page once we're
            # logged in, without being redirected...
            if self.is_on_page(LoginPage):
                # ... so we have to move by ourselves
                self.move_to_accounts_list()