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


Python Manifest.fetch方法代码示例

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


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

示例1: _unit_inventory

# 需要导入模块: from pulp_node.manifest import Manifest [as 别名]
# 或者: from pulp_node.manifest.Manifest import fetch [as 别名]
    def _unit_inventory(self, request):
        """
        Build the unit inventory.
        :param request: A synchronization request.
        :type request: SyncRequest
        :return: The built inventory.
        :rtype: UnitInventory
        """
        # fetch child units
        try:
            conduit = NodesConduit()
            child_units = conduit.get_units(request.repo_id)
        except NodeError:
            raise
        except Exception:
            log.exception(request.repo_id)
            raise GetChildUnitsError(request.repo_id)

        # fetch parent units
        try:
            request.progress.begin_manifest_download()
            url = request.config.get(constants.MANIFEST_URL_KEYWORD)
            manifest = Manifest()
            manifest.fetch(url, request.working_dir, request.downloader)
            manifest.fetch_units(url, request.downloader)
            parent_units = manifest.get_units()
        except NodeError:
            raise
        except Exception:
            log.exception(request.repo_id)
            raise GetParentUnitsError(request.repo_id)

        return UnitInventory(parent_units, child_units)
开发者ID:tomlanyon,项目名称:pulp,代码行数:35,代码来源:strategies.py

示例2: test_publisher

# 需要导入模块: from pulp_node.manifest import Manifest [as 别名]
# 或者: from pulp_node.manifest.Manifest import fetch [as 别名]
 def test_publisher(self):
     # setup
     units = self.populate()
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     with HttpPublisher(base_url, virtual_host, repo_id) as p:
         p.publish(units)
         p.commit()
     # verify
     conf = DownloaderConfig()
     downloader = HTTPSCurlDownloader(conf)
     manifest_path = p.manifest_path()
     working_dir = os.path.join(self.tmpdir, 'working_dir')
     os.makedirs(working_dir)
     manifest = Manifest()
     url = pathlib.url_join(base_url, manifest_path)
     manifest.fetch(url, working_dir, downloader)
     manifest.fetch_units(url, downloader)
     units = manifest.get_units()
     n = 0
     for unit, ref in units:
         if n == 0:
             self.assertTrue(unit[constants.PUBLISHED_AS_TARBALL])
         else:
             self.assertFalse(unit.get(constants.PUBLISHED_AS_TARBALL, False))
         path = pathlib.join(publish_dir, repo_id, unit[constants.RELATIVE_PATH])
         self.assertEqual(
             manifest.publishing_details[constants.BASE_URL],
             pathlib.url_join(base_url, publish_dir, repo_id))
         if n == 0:
             self.assertTrue(os.path.isfile(path))
         else:
             self.assertTrue(os.path.islink(path))
         if n == 0:
             tb = tarfile.open(path)
             try:
                 files = sorted(tb.getnames())
             finally:
                 tb.close()
             self.assertEqual(len(files), self.NUM_TARED_FILES + 1)
         else:
             with open(path, 'rb') as fp:
                 unit_content = fp.read()
                 self.assertEqual(unit_content, unit_content)
         self.assertEqual(unit['unit_key']['n'], n)
         n += 1
开发者ID:cliffy94,项目名称:pulp,代码行数:52,代码来源:test_publishers.py

示例3: test_publisher

# 需要导入模块: from pulp_node.manifest import Manifest [as 别名]
# 或者: from pulp_node.manifest.Manifest import fetch [as 别名]
 def test_publisher(self):
     # setup
     units = []
     for n in range(0, 3):
         fn = 'test_%d' % n
         relative_path = os.path.join(self.RELATIVE_PATH, fn)
         path = os.path.join(self.unit_dir, relative_path)
         fp = open(path, 'w')
         fp.write(fn)
         fp.close()
         unit = {'type_id':'unit', 'unit_key':{'n':n}, 'storage_path':path, 'relative_path':relative_path}
         units.append(unit)
     # test
     # publish
     repo_id = 'test_repo'
     base_url = 'file://'
     publish_dir = os.path.join(self.tmpdir, 'nodes/repos')
     virtual_host = (publish_dir, publish_dir)
     p = HttpPublisher(base_url, virtual_host, repo_id)
     p.publish(units)
     # verify
     conf = DownloaderConfig()
     downloader = HTTPSCurlDownloader(conf)
     manifest_path = p.manifest_path()
     working_dir = os.path.join(self.tmpdir, 'working_dir')
     os.makedirs(working_dir)
     manifest = Manifest()
     url = 'file://' + manifest_path
     manifest.fetch(url, working_dir, downloader)
     manifest.fetch_units(url, downloader)
     units = manifest.get_units()
     n = 0
     for unit, ref in units:
         file_content = 'test_%d' % n
         _download = unit['_download']
         url = _download['url']
         self.assertEqual(url, '/'.join((base_url, publish_dir[1:], repo_id, unit['relative_path'])))
         path = url.split('//', 1)[1]
         self.assertTrue(os.path.islink(path))
         f = open(path)
         s = f.read()
         f.close()
         self.assertEqual(s, file_content)
         self.assertEqual(unit['unit_key']['n'], n)
         n += 1
开发者ID:tomlanyon,项目名称:pulp,代码行数:47,代码来源:test_publishers.py


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