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


Python Module.generate_unit_key方法代码示例

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


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

示例1: test_generate_unit_key

# 需要导入模块: from pulp_puppet.common.model import Module [as 别名]
# 或者: from pulp_puppet.common.model.Module import generate_unit_key [as 别名]
    def test_generate_unit_key(self):
        # Test
        key = self.command.generate_unit_key(self.filename)

        # Verify
        expected_key = Module.generate_unit_key('valid', '1.0.0', 'jdob')
        self.assertEqual(key, expected_key)
开发者ID:ehelms,项目名称:pulp,代码行数:9,代码来源:test_extension_upload.py

示例2: test_generate_unit_key_complex_version

# 需要导入模块: from pulp_puppet.common.model import Module [as 别名]
# 或者: from pulp_puppet.common.model.Module import generate_unit_key [as 别名]
    def test_generate_unit_key_complex_version(self):
        filename = os.path.join(MODULES_DIR, 'jdob-valid-1.0.0-rc1.tar.gz')

        # Test
        key = self.command.generate_unit_key(filename)

        # Verify
        expected_key = Module.generate_unit_key('valid', '1.0.0-rc1', 'jdob')
        self.assertEqual(key, expected_key)
开发者ID:asmacdo,项目名称:pulp_puppet,代码行数:11,代码来源:test_extension_upload.py

示例3: _add_new_module

# 需要导入模块: from pulp_puppet.common.model import Module [as 别名]
# 或者: from pulp_puppet.common.model.Module import generate_unit_key [as 别名]
            if self._canceled:
                break
            module = modules_by_key[key]
            try:
                self._add_new_module(downloader, module)
                self.progress_report.modules_finished_count += 1
            except Exception, e:
                self.progress_report.add_failed_module(module, e, sys.exc_info()[2])

            self.progress_report.update_progress()

        # Remove missing units if the configuration indicates to do so
        if self._should_remove_missing():
            existing_units_by_key = {}
            for u in existing_units:
                unit_key = Module.generate_unit_key(u.unit_key['name'], u.unit_key['version'], u.unit_key['author'])
                s = unit_key_str(unit_key)
                existing_units_by_key[s] = u

            for key in remove_unit_keys:
                doomed = existing_units_by_key[key]
                self.sync_conduit.remove_unit(doomed)

        self.downloader = None

    def _add_new_module(self, downloader, module):
        """
        Performs the tasks for downloading and saving a new unit in Pulp.

        :param downloader: downloader instance to use for retrieving the unit
        :param module: module instance to download
开发者ID:hjensas,项目名称:pulp_puppet,代码行数:33,代码来源:forge.py

示例4: generate_unit_key

# 需要导入模块: from pulp_puppet.common.model import Module [as 别名]
# 或者: from pulp_puppet.common.model.Module import generate_unit_key [as 别名]
 def generate_unit_key(self, filename, **kwargs):
     root_filename = os.path.basename(filename)
     root_filename = root_filename[:-len('.tar.gz')]
     author, name, version = root_filename.split('-', 2)
     unit_key = Module.generate_unit_key(name, version, author)
     return unit_key
开发者ID:abhaychrungoo,项目名称:pulp_puppet,代码行数:8,代码来源:upload.py

示例5: _do_import_modules

# 需要导入模块: from pulp_puppet.common.model import Module [as 别名]
# 或者: from pulp_puppet.common.model.Module import generate_unit_key [as 别名]
    def _do_import_modules(self, metadata):
        """
        Actual logic of the import. This method will do a best effort per module;
        if an individual module fails it will be recorded and the import will
        continue. This method will only raise an exception in an extreme case
        where it cannot react and continue.
        """

        def unit_key_str(unit_key_dict):
            """
            Converts the unit key dict form into a single string that can be
            used as the key in a dict lookup.
            """
            template = '%s-%s-%s'
            return template % (encode_unicode(unit_key_dict['name']),
                               encode_unicode(unit_key_dict['version']),
                               encode_unicode(unit_key_dict['author']))

        downloader = self._create_downloader()

        # Ease lookup of modules
        modules_by_key = dict([(unit_key_str(m.unit_key()), m) for m in metadata.modules])

        # Collect information about the repository's modules before changing it
        module_criteria = UnitAssociationCriteria(type_ids=[constants.TYPE_PUPPET_MODULE])
        existing_units = self.sync_conduit.get_units(criteria=module_criteria)
        existing_modules = [Module.from_unit(x) for x in existing_units]
        existing_module_keys = [unit_key_str(m.unit_key()) for m in existing_modules]

        new_unit_keys = self._resolve_new_units(existing_module_keys, modules_by_key.keys())
        remove_unit_keys = self._resolve_remove_units(existing_module_keys, modules_by_key.keys())

        # Once we know how many things need to be processed, we can update the
        # progress report
        self.progress_report.modules_total_count = len(new_unit_keys)
        self.progress_report.modules_finished_count = 0
        self.progress_report.modules_error_count = 0
        self.progress_report.update_progress()

        # Add new units
        for key in new_unit_keys:
            module = modules_by_key[key]
            try:
                self._add_new_module(downloader, module)
                self.progress_report.modules_finished_count += 1
            except Exception:
                self.progress_report.add_failed_module(module, sys.exc_info()[2])

            self.progress_report.update_progress()

        # Remove missing units if the configuration indicates to do so
        if self._should_remove_missing():
            existing_units_by_key = {}
            for u in existing_units:
                unit_key = Module.generate_unit_key(u.unit_key['name'], u.unit_key['version'], u.unit_key['author'])
                s = unit_key_str(unit_key)
                existing_units_by_key[s] = u

            for key in remove_unit_keys:
                doomed = existing_units_by_key[key]
                self.sync_conduit.remove_unit(doomed)
开发者ID:jlsherrill,项目名称:pulp,代码行数:63,代码来源:sync.py


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