• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python repo_file.RepoFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp_rpm.handler.repo_file.RepoFile的典型用法代码示例。如果您正苦于以下问题:Python RepoFile类的具体用法?Python RepoFile怎么用?Python RepoFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_bind_multiple_url

    def test_bind_multiple_url(self):
        """
        Tests that binding with a list of URLs will produce a mirror list and the
        correct mirrorlist entry in the repo entry.
        """

        # Test
        url_list = ['http://pulpserver', 'http://otherserver']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)

        # Verify
        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertTrue('baseurl' not in loaded)
        self.assertEqual(loaded['mirrorlist'], 'file:' + TEST_MIRROR_LIST_FILENAME)

        mirror_list_file = MirrorListFile(TEST_MIRROR_LIST_FILENAME)
        mirror_list_file.load()

        self.assertEqual(mirror_list_file.entries[0], 'http://pulpserver')
        self.assertEqual(mirror_list_file.entries[1], 'http://otherserver')
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:26,代码来源:test_repolib.py


示例2: test_bind_update_keys

    def test_bind_update_keys(self):
        """
        Tests changing the GPG keys on a previously bound repo.
        """

        # Setup
        keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], keys, None, None, ENABLED, LOCK)

        # Test
        new_keys = {'key1' : 'KEYX'}
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, None, None, new_keys, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['gpgcheck'], '1')
        self.assertEqual(1, len(loaded['gpgkey'].split('\n')))
        self.assertEqual(1, len(os.listdir(os.path.join(TEST_KEYS_DIR, REPO_ID))))

        key_file = open(loaded['gpgkey'].split('\n')[0][5:], 'r')
        contents = key_file.read()
        key_file.close()

        self.assertEqual(contents, 'KEYX')
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:27,代码来源:test_repolib.py


示例3: test_one_repo_save_and_load

    def test_one_repo_save_and_load(self):
        """
        Tests the normal flow of saving and loading, using only one repo to
        minimize complications.
        """

        # Setup
        add_me = Repo('test-repo-1')
        add_me['baseurl'] = 'http://localhost/repo'
        add_me['enabled'] = 1
        add_me['gpgkey'] = '/tmp/key'
        add_me['sslverify'] = 0
        add_me['gpgcheck'] = 0
        add_me['sslcacert'] = '/tmp/sslcacert'
        add_me['sslclientcert'] = '/tmp/clientcert'

        repo_file = RepoFile(TEST_REPO_FILENAME)

        # Test Save
        repo_file.add_repo(add_me)
        repo_file.save()

        # Verify Save
        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))

        # Test Load
        loaded = RepoFile(TEST_REPO_FILENAME)
        loaded.load()

        # Verify Load
        self.assertEqual(1, len(loaded.all_repos()))

        found_repo = loaded.get_repo('test-repo-1')
        self.assertTrue(found_repo is not None)
        self.assertTrue(_repo_eq(add_me, found_repo))
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:35,代码来源:test_repo_file.py


示例4: test_broken_load_allow_missing

    def test_broken_load_allow_missing(self):
        """
        Tests that an exception is raised when the file cannot be loaded because it is not
        found.
        """

        # Test
        repo_file = RepoFile('/a/b/c/d')
        repo_file.load(allow_missing=True)
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:9,代码来源:test_repo_file.py


示例5: test_add_duplicate

    def test_add_duplicate(self):
        """
        Tests that adding a repo that already exists throws a duplication error.
        """

        # Setup
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.add_repo(Repo('foo'))

        # Test
        self.assertRaises(DuplicateSectionError, repo_file.add_repo, Repo('foo'))
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:11,代码来源:test_repo_file.py


示例6: test_delete_file_doesnt_exist

    def test_delete_file_doesnt_exist(self):
        """
        Tests that deleting when the file doesn't exist does *not* throw an error.
        """

        # Setup
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))

        # Test
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.delete()
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:11,代码来源:test_repo_file.py


示例7: test_get_invalid_repo

    def test_get_invalid_repo(self):
        """
        Makes sure None is returned when requesting a repo that doesn't exist
        instead of throwing an error.
        """

        # Setup
        repo_file = RepoFile(TEST_REPO_FILENAME)

        # Test
        found = repo_file.get_repo('foo')

        # Verify
        self.assertTrue(found is None)
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:14,代码来源:test_repo_file.py


示例8: test_header

    def test_header(self):
        """
        Tests that the pulp header is properly written in the generated file.
        """

        # Setup
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.save()

        # Test
        f = open(TEST_REPO_FILENAME, 'r')
        contents = f.read()
        f.close()

        # Verify
        self.assertTrue(contents.startswith(RepoFile.FILE_HEADER))
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:16,代码来源:test_repo_file.py


示例9: test_update_clientcert

 def test_update_clientcert(self):
     # setup
     NEWCLIENTCRT = 'THE-NEW-CLIENT-CERT'
     repolib.bind(
         TEST_REPO_FILENAME,
         TEST_MIRROR_LIST_FILENAME,
         TEST_KEYS_DIR,
         TEST_CERT_DIR,
         REPO_ID,
         REPO_NAME,
         ['http://pulp'],
         [], 
         CACERT, 
         CLIENTCERT,
         ENABLED,
         LOCK)
     repolib.bind(
         TEST_REPO_FILENAME,
         TEST_MIRROR_LIST_FILENAME,
         TEST_KEYS_DIR,
         TEST_CERT_DIR,
         REPO_ID,
         REPO_NAME,
         ['http://pulp'], 
         [],
         CACERT, 
         NEWCLIENTCRT,
         ENABLED,
         LOCK)
     repo_file = RepoFile(TEST_REPO_FILENAME)
     repo_file.load()
     loaded = repo_file.get_repo(REPO_ID)
     # verify
     certdir = os.path.join(TEST_CERT_DIR, REPO_ID)
     self.assertTrue(len(os.listdir(certdir)), 2)
     path = loaded['sslcacert']
     f = open(path)
     content = f.read()
     f.close()
     self.assertEqual(CACERT, content)
     path = loaded['sslclientcert']
     f = open(path)
     content = f.read()
     f.close()
     self.assertEqual(NEWCLIENTCRT, content)
     self.assertTrue(loaded['sslverify'], '1')
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:46,代码来源:test_repolib.py


示例10: test_delete_repofile

    def test_delete_repofile(self):
        """
        Tests that deleting a RepoFile correctly deletes the file on disk.
        """

        # Setup
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.save()

        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))

        # Test
        repo_file.delete()

        # Verify
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:18,代码来源:test_repo_file.py


示例11: test_bind_single_url

    def test_bind_single_url(self):
        """
        Tests that binding with a single URL will produce a baseurl in the repo.
        """

        # Test
        url_list = ['http://pulpserver']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)

        # Verify
        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['baseurl'], url_list[0])
        self.assertTrue('mirrorlist' not in loaded)
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:19,代码来源:test_repolib.py


示例12: test_bind_multiple_keys

    def test_bind_multiple_keys(self):
        """
        Tests that binding with multiple key URLs correctly stores the repo entry.
        """

        # Test
        url_list = ['http://pulpserver']
        keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}

        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, keys, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['gpgcheck'], '1')
        self.assertEqual(2, len(loaded['gpgkey'].split('\n')))
        self.assertEqual(2, len(os.listdir(os.path.join(TEST_KEYS_DIR, REPO_ID))))
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:19,代码来源:test_repolib.py


示例13: test_bind_host_urls_many_to_one

    def test_bind_host_urls_many_to_one(self):
        """
        Tests that changing from multiple URLs (mirrorlist usage) to a single URL
        properly sets the repo metadata.
        """
        # Setup
        url_list = ['http://pulp1', 'http://pulp2']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)

        # Test
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulpx'], None, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertTrue('baseurl' in loaded)
        self.assertTrue('mirrorlist' not in loaded)
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:19,代码来源:test_repolib.py


示例14: test_bind_host_urls_one_to_many

    def test_bind_host_urls_one_to_many(self):
        """
        Tests that changing from a single URL to many properly updates the baseurl and
        mirrorlist entries of the repo.
        """

        # Setup
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['https://pulpx'], None, None, None, ENABLED, LOCK)

        # Test
        url_list = ['http://pulp1', 'http://pulp2']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertTrue('baseurl' not in loaded)
        self.assertTrue('mirrorlist' in loaded)
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:20,代码来源:test_repolib.py


示例15: test_unbind_repo_with_mirrorlist

    def test_unbind_repo_with_mirrorlist(self):
        """
        Tests that unbinding a repo that had a mirror list deletes the mirror list
        file.
        """

        # Setup
        url_list = ['http://pulp1', 'http://pulp2', 'http://pulp3']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()
        self.assertEqual(0, len(repo_file.all_repos()))

        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:20,代码来源:test_repolib.py


示例16: test_bind_update_remove_keys

    def test_bind_update_remove_keys(self):
        """
        Tests that updating a previously bound repo by removing its keys correctly
        configures the repo and deletes the key files.
        """

        # Setup
        keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], keys, None, None, ENABLED, LOCK)

        # Test
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, None, None, {}, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['gpgcheck'], '0')
        self.assertEqual(loaded['gpgkey'], None)
        self.assertTrue(not os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:21,代码来源:test_repolib.py


示例17: test_bind_update_repo

    def test_bind_update_repo(self):
        """
        Tests calling bind on an existing repo with new repo data. The host URL and key data
        remain unchanged.
        """

        # Setup
        url_list = ['http://pulp1', 'http://pulp2']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)

        # Test
        updated_name = 'Updated'

        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, updated_name, None, None, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['name'], updated_name)
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:21,代码来源:test_repolib.py


示例18: delete_repo_file

def delete_repo_file(repo_filename, lock=None):
    """
    Delete the repo file.

    @param repo_filename: full path to the location of the repo file which
                          will be deleted; if this file does not exist
                          this call has no effect
    @type  repo_filename: string

    @param lock: if the default lock is unacceptable, it may be overridden in this variable
    @type  lock: L{Lock}
    """
    if not lock:
        lock = Lock(LOCK_FILE)

    lock.acquire()
    try:
        repo_file = RepoFile(repo_filename)
        repo_file.delete()
    finally:
        lock.release()
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:21,代码来源:repolib.py


示例19: test_bind_new_file

    def test_bind_new_file(self):
        """
        Tests binding a repo when the underlying .repo file does not exist.
        """

        # Test
        url_list = ['http://pulpserver']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, CACERT, CLIENTCERT, ENABLED, LOCK)

        # Verify
        self.assertTrue(os.path.exists(TEST_REPO_FILENAME))
        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        self.assertEqual(1, len(repo_file.all_repos()))

        loaded = repo_file.get_repo(REPO_ID)
        self.assertTrue(loaded is not None)
        self.assertEqual(loaded['name'], REPO_NAME)
        self.assertTrue(loaded['enabled'])
        self.assertEqual(loaded['gpgcheck'], '0')
        self.assertEqual(loaded['gpgkey'], None)

        self.assertEqual(loaded['baseurl'], url_list[0])
        self.assertTrue('mirrorlist' not in loaded)
        
        path = loaded['sslcacert']
        f = open(path)
        content = f.read()
        f.close()
        self.assertEqual(CACERT, content)
        path = loaded['sslclientcert']
        f = open(path)
        content = f.read()
        f.close()
        self.assertEqual(CLIENTCERT, content)
        self.assertTrue(loaded['sslverify'], '1')
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:39,代码来源:test_repolib.py


示例20: test_bind_update_host_urls

    def test_bind_update_host_urls(self):
        """
        Tests calling bind on an existing repo with new repo data. This test will test
        the more complex case where a mirror list existed in the original repo but is
        not necessary in the updated repo.
        """

        # Setup
        url_list = ['http://pulp1', 'http://pulp2']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, None, None, None, ENABLED, LOCK)

        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        # Test
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, None, ['http://pulpx'], None, None, None, ENABLED, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()

        loaded = repo_file.get_repo(REPO_ID)
        self.assertEqual(loaded['baseurl'], 'http://pulpx')

        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
开发者ID:ehelms,项目名称:pulp_rpm,代码行数:24,代码来源:test_repolib.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python repo_file.RepoFile类代码示例发布时间:2022-05-25
下一篇:
Python importer_mocks.get_basic_config函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap