Exemplo n.º 1
0
 def hgsid(self):
     """
     Get a new hgsid if one has not been set or if the mirror has changed;
     otherwise return the existing one.
     """
     if (settings.hgsid is None) or (self._mirror != settings.mirror):
         hgsid_logger.debug("new hgsid: %s" % settings.hgsid)
         settings.hgsid = helpers.hgsid_from_response(requests.get(self.gateway_url))
     hgsid_logger.debug("hgsid=%s" % settings.hgsid)
     return settings.hgsid
Exemplo n.º 2
0
    def login(self, username, password=None):
        """
        Log in using username and password

        If `password` is None, then prompt for it at the terminal.
        """
        if password is None:
            password = getpass.getpass(prompt="\nPassword for %s: " % self.url)
        hgsid_logger.debug("pre-login hgsid: %s" % self.hgsid)
        response = self.session.post(
            self.login_url,
            data={"hgLogin_username": username, "hgLogin_password": password, "action": "hgLogin", "hgsid": None},
        )
        self.update_session(["hgLogin_username"])
        settings.hgsid = helpers.hgsid_from_response(response)
        hgsid_logger.debug("post-login hgsid: %s" % self.hgsid)
        response = self.session.get(self.session_url)
        return response
Exemplo n.º 3
0
    def login(self, username, password=None):
        """
        Log in using username and password

        If `password` is None, then prompt for it at the terminal.
        """
        if password is None:
            password = getpass.getpass(prompt='\nPassword for %s: ' % self.url)
        hgsid_logger.debug('pre-login hgsid: %s' % self.hgsid)
        response = self.session.post(self.login_url, data={
            'hgLogin_username': username,
            'hgLogin_password': password,
            'action': 'hgLogin',
            'hgsid': None})
        self.update_session(['hgLogin_username'])
        settings.hgsid = helpers.hgsid_from_response(response)
        hgsid_logger.debug('post-login hgsid: %s' % self.hgsid)
        response = self.session.get(self.session_url)
        return response