コード例 #1
0
    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_errors(self):
        package = PackageDescription(name="foo")
        config = PyPIConfig.from_string("""
[distutils]
index-servers = pypi

[pypi]
username = cdavid
password = yoyo
server = http://testpypi.python.org
""")

        post_data = build_post_data(package, "submit")
        return post_to_server(post_data, config)
コード例 #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
ファイル: test_register_utils.py プロジェクト: pv/bento
    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")
コード例 #5
0
ファイル: test_register_utils.py プロジェクト: pv/bento
    def _test_register_server_errors(self):
        package = PackageDescription(name="foo")
        config = PyPIConfig.from_string(
            """
[distutils]
index-servers = pypi

[pypi]
username = cdavid
password = yoyo
server = http://testpypi.python.org
"""
        )

        post_data = build_post_data(package, "submit")
        return post_to_server(post_data, config)
コード例 #6
0
ファイル: test_register_utils.py プロジェクト: pv/bento
    def test_build_post_data(self):
        r_content = six.b(
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="maintainer"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="name"\r\n\r\n"""
            """foo\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="license"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="author"\r\n\r\n"""
            """John Doe\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="url"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name=":action"\r\n\r\n"""
            """submit\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="download_url"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="maintainer_email"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="author_email"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="version"\r\n\r\n"""
            """1.0\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="long_description"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n"""
            """Content-Disposition: form-data; name="description"\r\n\r\n\r\n"""
            """----------------GHSKFJDLGDS7543FJKLFHRE75642756743254--\r\n"""
            """"""
        )
        bento_info = """\
Name: foo
Version: 1.0
Author: John Doe
"""
        package = PackageDescription.from_string(bento_info)
        post_data = build_post_data(package, "submit")
        content_type, body = encode_multipart(post_data.items(), [])
        self.assertEqual(r_content, body)
コード例 #7
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)
コード例 #8
0
    def test_build_post_data(self):
        r_content = six.b("""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="maintainer"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="name"\r\n\r\n""" \
"""foo\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="license"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="author"\r\n\r\n""" \
"""John Doe\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="url"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name=":action"\r\n\r\n""" \
"""submit\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="download_url"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="maintainer_email"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="author_email"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="version"\r\n\r\n""" \
"""1.0\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="long_description"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254\r\n""" \
"""Content-Disposition: form-data; name="description"\r\n\r\n\r\n""" \
"""----------------GHSKFJDLGDS7543FJKLFHRE75642756743254--\r\n""" \
"""""")
        bento_info = """\
Name: foo
Version: 1.0
Author: John Doe
"""
        package = PackageDescription.from_string(bento_info)
        post_data = build_post_data(package, "submit")
        content_type, body = encode_multipart(list(post_data.items()), [])
        self.assertEqual(r_content, body)