def __init__(self, origin_url, username, password, expiration=60,
                 html_login=True):
        if username is not None and password is not None:
            self._pwdmgr.add_password(None,
                                      origin_url,
                                      username,
                                      password)
        self._html_login = html_login
        self._expiration = expiration
        url1 = compat.urljoin(origin_url, '../../tokens/generateToken', False)
        url2 = compat.urljoin(origin_url, '../tokens/generateToken', False)
        url3 = compat.urljoin(origin_url, './generateToken', False)
        url4 = compat.urljoin(origin_url, '/admin/generateToken', False)
        url5 = compat.urljoin(origin_url, '/generateToken', False)
        self._referer = url1
        for url in (url1, url2, url3, url4, url5):
            try:
                self._referer = url
                url_tuple = compat.urlsplit(url)
                urllist = list(url_tuple)
                query_dict = dict((k, v[0]) for k, v in 
                                  cgi.parse_qs(urllist[3]).items())
                query_dict['username'] = username
                query_dict['password'] = password
                self._username = username
                self._password = password
                query_dict['expiration'] = str(self._expiration)
                query_dict['client'] = 'requestip'
                urllist[3] = compat.urlencode(query_dict)
                url = compat.urlunsplit(urllist)
                super(GenerateToken, self).__init__(url)
                self._json_struct['token']
                return
            except compat.urllib2.HTTPError:
                pass
            except __HOLE__:
                pass
        raise compat.urllib2.HTTPError(origin_url, 401, "Could not create token using URL {}"
                                .format(origin_url), None, None)
dataset/ETHPy150Open jasonbot/arcrest/arcrest/server.py/GenerateToken.__init__