def run(self, context):
        o, a = context.get_parsed_arguments()
        if o.repository and (o.username or o.password or o.repository_url):
            raise bento.errors.UsageException(
                "Cannot specify repository and username/password/url at the same time"
            )
        if not (o.repository or
                (o.username or o.password or o.repository_url)):
            # FIXME: why does distutils use DEFAULT_REPOSITORY (i.e. an url)
            # here ?
            config = _read_pypirc(DEFAULT_REPOSITORY)
        elif o.repository:
            config = _read_pypirc(o.repository)
        else:
            config = PyPIConfig(o.username, o.password, o.repository_url)

        auth = HTTPPasswordMgr()
        host = urlparse(config.repository)[1]
        auth.add_password(config.realm, host, config.username, config.password)

        post_data = build_post_data(context.pkg, "submit")
        code, msg = post_to_server(post_data, config, auth)
        if code != 200:
            raise bento.errors.BentoError(
                "Error while submitting package metadata to server: %r" % msg)
示例#2
0
    def test_register_server(self):
        package = PackageDescription(name="foo")
        repository = 'http://testpypi.python.org/pypi'
        realm = DEFAULT_REALM
        config = PyPIConfig(username="******", password="******", repository=repository, realm=realm)

        auth = HTTPPasswordMgr()
        host = urlparse(config.repository)[0]
        auth.add_password(config.realm, host, config.username, config.password)

        post_data = build_post_data(package, "submit")
        code, msg = post_to_server(post_data, config, auth)
        self.assertEqual(code, 200)
        self.assertEqual(msg, "OK")
示例#3
0
    def test_register_server(self):
        package = PackageDescription(name="foo")
        repository = "http://testpypi.python.org/pypi"
        realm = DEFAULT_REALM
        config = PyPIConfig(username="******", password="******", repository=repository, realm=realm)

        auth = HTTPPasswordMgr()
        host = urlparse(config.repository)[0]
        auth.add_password(config.realm, host, config.username, config.password)

        post_data = build_post_data(package, "submit")
        code, msg = post_to_server(post_data, config, auth)
        self.assertEqual(code, 200)
        self.assertEqual(msg, "OK")
示例#4
0
    def __init__(self, password_mgr=None, debuglevel=0):
        """Initialize an instance of a AbstractAuthHandler.

Verify operation with all default arguments.
>>> abstrct = AbstractAuthHandler()

Verify "normal" operation.
>>> abstrct = AbstractAuthHandler(urllib2.HTTPPasswordMgrWithDefaultRealm())
"""
        super(AuthHandler, self).__init__(logging.getLogger('urllib_auth'))

        if password_mgr is None:
            password_mgr = HTTPPasswordMgr()

        self.parent = None
        self.passwd = password_mgr
        self.add_password = self.passwd.add_password

        self._debuglevel = debuglevel

        self._basic = AbstractBasicAuthHandler(password_mgr=self.passwd)
        self._digest = AbstractDigestAuthHandler(passwd=self.passwd)

        self.auth_header_request = None
        self.auth_header_response = None
        self.auth_is_proxy = None
        self.auth_code = None
示例#5
0
    def __init__(self, password_mgr=None):
        """
        Initialize a new FTPBasicAuthHandler.
        """

        if password_mgr is None:
            password_mgr = HTTPPasswordMgr()
        self.passwd = password_mgr
        self.add_password = self.passwd.add_password
        return super().__init__()
示例#6
0
文件: register.py 项目: B-Rich/Bento
    def run(self, context):
        o, a = context.get_parsed_arguments()
        if o.repository and (o.username or o.password or o.repository_url):
            raise bento.errors.UsageException("Cannot specify repository and username/password/url at the same time")
        if not (o.repository or (o.username or o.password or o.repository_url)):
            # FIXME: why does distutils use DEFAULT_REPOSITORY (i.e. an url)
            # here ?
            config = _read_pypirc(DEFAULT_REPOSITORY)
        elif o.repository:
            config = _read_pypirc(o.repository)
        else:
            config = PyPIConfig(o.username, o.password, o.repository_url)

        auth = HTTPPasswordMgr()
        host = urlparse(config.repository)[1]
        auth.add_password(config.realm, host, config.username, config.password)

        post_data = build_post_data(context.pkg, "submit")
        code, msg = post_to_server(post_data, config, auth)
        if code != 200:
            raise bento.errors.BentoError("Error while submitting package metadata to server: %r" % msg)
示例#7
0
文件: _auth.py 项目: sfall/mechanize3
 def find_key_cert(self, authuri):
     return HTTPPasswordMgr.find_user_password(self, None, authuri)
示例#8
0
文件: _auth.py 项目: sfall/mechanize3
 def is_suburi(self, base, test):
     if base is None:
         # default to the proxy's host/port
         hostport, path = test
         base = (hostport, "/")
     return HTTPPasswordMgr.is_suburi(self, base, test)
示例#9
0
文件: _auth.py 项目: sfall/mechanize3
 def reduce_uri(self, uri, default_port=True):
     if uri is None:
         return None
     return HTTPPasswordMgr.reduce_uri(self, uri, default_port)
示例#10
0
 def __init__(self, password_mgr=None):
     if password_mgr is None:
         password_mgr = HTTPPasswordMgr()
     self.passwd = password_mgr
     self.add_password = self.passwd.add_password
示例#11
0
文件: _auth.py 项目: sfall/mechanize3
 def find_key_cert(self, authuri):
     return HTTPPasswordMgr.find_user_password(self, None, authuri)
示例#12
0
文件: _auth.py 项目: sfall/mechanize3
 def is_suburi(self, base, test):
     if base is None:
         # default to the proxy's host/port
         hostport, path = test
         base = (hostport, "/")
     return HTTPPasswordMgr.is_suburi(self, base, test)
示例#13
0
文件: _auth.py 项目: sfall/mechanize3
 def reduce_uri(self, uri, default_port=True):
     if uri is None:
         return None
     return HTTPPasswordMgr.reduce_uri(self, uri, default_port)