当前位置: 首页>>代码示例>>Python>>正文


Python upload.upload方法代码示例

本文整理汇总了Python中distutils.command.upload.upload方法的典型用法代码示例。如果您正苦于以下问题:Python upload.upload方法的具体用法?Python upload.upload怎么用?Python upload.upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.command.upload的用法示例。


在下文中一共展示了upload.upload方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_saved_password

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_saved_password(self):
        # file with no password
        self.write_file(self.rc, PYPIRC_NOPASSWORD)

        # make sure it passes
        dist = Distribution()
        cmd = upload(dist)
        cmd.finalize_options()
        self.assertEqual(cmd.password, None)

        # make sure we get it as well, if another command
        # initialized it at the dist level
        dist.password = 'xxx'
        cmd = upload(dist)
        cmd.finalize_options()
        self.assertEqual(cmd.password, 'xxx') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_upload.py

示例2: test_upload_correct_cr

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload_correct_cr(self):
        # content that ends with \r should not be modified.
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path, content='yy\r')
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # other fields that ended with \r used to be modified, now are
        # preserved.
        pkg_dir, dist = self.create_dist(
            dist_files=dist_files,
            description='long description\r'
        )
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.run()

        headers = dict(self.last_open.req.headers)
        self.assertEqual(headers['Content-length'], '2170')
        self.assertIn(b'long description\r', self.last_open.req.data)
        self.assertNotIn(b'long description\r\n', self.last_open.req.data) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_upload.py

示例3: test_upload

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload(self):
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # lets run it
        pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.run()

        # what did we send ?
        self.assertIn('dédé', self.last_open.req.data)
        headers = dict(self.last_open.req.headers)
        self.assertEqual(headers['Content-length'], '2085')
        self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
        self.assertEqual(self.last_open.req.get_method(), 'POST')
        self.assertEqual(self.last_open.req.get_full_url(),
                         'http://pypi.python.org/pypi')
        self.assertTrue('xxx' in self.last_open.req.data)
        auth = self.last_open.req.headers['Authorization']
        self.assertFalse('\n' in auth) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:test_upload.py

示例4: test_upload

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload(self):
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # lets run it
        pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.run()

        # what did we send ?
        self.assertIn('dédé', self.last_open.req.data)
        headers = dict(self.last_open.req.headers)
        self.assertEqual(headers['Content-length'], '2159')
        self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
        self.assertEqual(self.last_open.req.get_method(), 'POST')
        self.assertEqual(self.last_open.req.get_full_url(),
                         'https://pypi.python.org/pypi')
        self.assertIn('xxx', self.last_open.req.data)
        auth = self.last_open.req.headers['Authorization']
        self.assertNotIn('\n', auth) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:27,代码来源:test_upload.py

示例5: test_upload_correct_cr

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload_correct_cr(self):
        # content that ends with \r should not be modified.
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path, content='yy\r')
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # other fields that ended with \r used to be modified, now are
        # preserved.
        pkg_dir, dist = self.create_dist(
            dist_files=dist_files,
            description='long description\r'
        )
        cmd = upload(dist)
        cmd.show_response = 1
        cmd.ensure_finalized()
        cmd.run()

        headers = dict(self.last_open.req.headers)
        self.assertEqual(headers['Content-length'], '2172')
        self.assertIn(b'long description\r', self.last_open.req.data) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:25,代码来源:test_upload.py

示例6: test_wrong_exception_order

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_wrong_exception_order(self):
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path)
        dist_files = [('xxx', '2.6', path)]  # command, pyversion, filename
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        pkg_dir, dist = self.create_dist(dist_files=dist_files)
        tests = [
            (OSError('oserror'), 'oserror', OSError),
            (HTTPError('url', 400, 'httperror', {}, None),
             'Upload failed (400): httperror', DistutilsError),
        ]
        for exception, expected, raised_exception in tests:
            with self.subTest(exception=type(exception).__name__):
                with mock.patch('distutils.command.upload.urlopen',
                                new=mock.Mock(side_effect=exception)):
                    with self.assertRaises(raised_exception):
                        cmd = upload(dist)
                        cmd.ensure_finalized()
                        cmd.run()
                    results = self.get_logs(ERROR)
                    self.assertIn(expected, results[-1])
                    self.clear_logs() 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:26,代码来源:test_upload.py

示例7: test_upload_correct_cr

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload_correct_cr(self):
        # content that ends with \r should not be modified.
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path, content='yy\r')
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # other fields that ended with \r used to be modified, now are
        # preserved.
        pkg_dir, dist = self.create_dist(
            dist_files=dist_files,
            description='long description\r'
        )
        cmd = upload(dist)
        cmd.show_response = 1
        cmd.ensure_finalized()
        cmd.run()

        headers = dict(self.last_open.req.headers)
        self.assertGreaterEqual(int(headers['Content-length']), 2172)
        self.assertIn(b'long description\r', self.last_open.req.data) 
开发者ID:pypa,项目名称:setuptools,代码行数:25,代码来源:test_upload.py

示例8: finalize_options

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def finalize_options(self):
        orig.upload.finalize_options(self)
        # Attempt to obtain password. Short circuit evaluation at the first
        # sign of success.
        self.password = (
            self.password or
            self._load_password_from_keyring() or
            self._prompt_for_password()
        ) 
开发者ID:jpush,项目名称:jbox,代码行数:11,代码来源:upload.py

示例9: run

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def run(self):
        try:
            orig.upload.run(self)
        finally:
            self.announce(
                "WARNING: Uploading via this command is deprecated, use twine "
                "to upload instead (https://pypi.org/p/twine/)",
                log.WARN
            ) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:upload.py

示例10: finalize_options

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def finalize_options(self):
        orig.upload.finalize_options(self)
        self.username = (
            self.username or
            getpass.getuser()
        )
        # Attempt to obtain password. Short circuit evaluation at the first
        # sign of success.
        self.password = (
            self.password or
            self._load_password_from_keyring() or
            self._prompt_for_password()
        ) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:15,代码来源:upload.py

示例11: test_finalize_options

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_finalize_options(self):

        # new format
        self.write_file(self.rc, PYPIRC)
        dist = Distribution()
        cmd = upload(dist)
        cmd.finalize_options()
        for attr, waited in (('username', 'me'), ('password', 'secret'),
                             ('realm', 'pypi'),
                             ('repository', 'https://upload.pypi.org/legacy/')):
            self.assertEqual(getattr(cmd, attr), waited) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_upload.py

示例12: test_upload

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def test_upload(self):
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # lets run it
        pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.run()

        # what did we send ?
        self.assertIn('dédé', self.last_open.req.data)
        headers = dict(self.last_open.req.headers)
        self.assertEqual(headers['Content-length'], '2159')
        self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
        self.assertEqual(self.last_open.req.get_method(), 'POST')
        self.assertEqual(self.last_open.req.get_full_url(),
                         'https://upload.pypi.org/legacy/')
        self.assertIn('xxx', self.last_open.req.data)
        auth = self.last_open.req.headers['Authorization']
        self.assertNotIn('\n', auth)

    # bpo-32304: archives whose last byte was b'\r' were corrupted due to
    # normalization intended for Mac OS 9. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:30,代码来源:test_upload.py

示例13: finalize_options

# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import upload [as 别名]
def finalize_options(self):
        orig.upload.finalize_options(self)
        self.password or self._load_password_from_keyring() 
开发者ID:awslabs,项目名称:lambda-chef-node-cleanup,代码行数:5,代码来源:upload.py


注:本文中的distutils.command.upload.upload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。