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

Python arg_utils.convert_removed_options函数代码示例

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

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



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

示例1: test_null_values

    def test_null_values(self):
        # Setup
        args = {'key1': None}

        # Assert that all the args with a value of None are removed
        arg_utils.convert_removed_options(args)
        self.assertEqual({}, args)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:7,代码来源:test_client_arg_utils.py


示例2: run

    def run(self, **kwargs):
        """
        Perform the update on the server.

        :param kwargs: The user input
        :type  kwargs: dict
        """
        arg_utils.convert_removed_options(kwargs)

        importer_config = self._parse_importer_config(kwargs)

        # Remove importer specific keys
        for key in importer_config.keys():
            kwargs.pop(key, None)

        if importer_config:
            kwargs['importer_config'] = importer_config

        # Update distributor configuration
        web_config = {}

        value = kwargs.pop(OPT_AUTO_PUBLISH.keyword, None)
        if value is not None:
            web_config['auto_publish'] = value

        if web_config:
            kwargs['distributor_configs'] = {}
            kwargs['distributor_configs'][constants.CLI_DISTRIBUTOR_ID] = web_config

        super(UpdatePythonRepositoryCommand, self).run(**kwargs)
开发者ID:bmbouter,项目名称:pulp_python,代码行数:30,代码来源:cudl.py


示例3: run

    def run(self, **kwargs):
        arg_utils.convert_removed_options(kwargs)

        importer_config = self.parse_user_input(kwargs)
        if OPT_PACKAGE_FILE_PATH.keyword in kwargs:
            importer_config[OPT_PACKAGE_FILE_PATH.keyword] = \
                kwargs.get(OPT_PACKAGE_FILE_PATH.keyword)

        # Remove importer specific keys
        for key in importer_config.keys():
            kwargs.pop(key, None)

        if importer_config:
            kwargs['importer_config'] = importer_config

        # Update distributor configuration
        web_config = {}

        value = kwargs.pop(OPT_AUTO_PUBLISH.keyword, None)
        if value is not None:
            web_config['auto_publish'] = value

        if web_config:
            kwargs['distributor_configs'] = {}
            kwargs['distributor_configs'][constants.CLI_WEB_DISTRIBUTOR_ID] = web_config

        super(UpdateDebRepositoryCommand, self).run(**kwargs)
开发者ID:sjtindell,项目名称:pulp_deb,代码行数:27,代码来源:cudl.py


示例4: run

    def run(self, **kwargs):
        arg_utils.convert_removed_options(kwargs)

        importer_config = self.parse_user_input(kwargs)

        if OPT_BRANCH.keyword in kwargs:
            value = kwargs.pop(OPT_BRANCH.keyword, None)
            if value == ['']:
                # clear out the specified branches
                value = None
            importer_config[constants.IMPORTER_CONFIG_KEY_BRANCHES] = value

        # Remove importer specific keys
        for key in importer_config.keys():
            kwargs.pop(key, None)

        if importer_config:
            kwargs['importer_config'] = importer_config

        # Update distributor configuration
        web_config = {}

        value = kwargs.pop(OPT_AUTO_PUBLISH.keyword, None)
        if value is not None:
            web_config['auto_publish'] = value

        if web_config:
            kwargs['distributor_configs'] = {}
            kwargs['distributor_configs'][constants.CLI_WEB_DISTRIBUTOR_ID] = web_config

        super(UpdateOSTreeRepositoryCommand, self).run(**kwargs)
开发者ID:bmbouter,项目名称:pulp_ostree,代码行数:31,代码来源:cudl.py


示例5: run

    def run(self, **kwargs):
        # -- importer metadata --
        queries = kwargs.pop(OPTION_QUERIES.keyword, None)
        if queries is None:
            queries = kwargs.pop(OPTION_QUERY.keyword, None)
        importer_config = self.parse_user_input(kwargs)
        importer_config.update({constants.CONFIG_QUERIES: queries})
        if importer_config:
            arg_utils.convert_removed_options(importer_config)
            kwargs['importer_config'] = importer_config

        # Remove the importer keys from kwargs so they don't get added to the repo config
        for key in importer_config:
            kwargs.pop(key, None)

        # -- distributor metadata --
        distributor_config = {
            constants.CONFIG_SERVE_HTTP: kwargs.pop(OPTION_HTTP.keyword, None),
            constants.CONFIG_SERVE_HTTPS: kwargs.pop(OPTION_HTTPS.keyword, None)
        }
        arg_utils.convert_removed_options(distributor_config)
        arg_utils.convert_boolean_arguments((constants.CONFIG_SERVE_HTTP,
                                             constants.CONFIG_SERVE_HTTPS), distributor_config)
        # Remove the distributor keys from kwargs so they don't get added to the repo config
        for key in distributor_config:
            kwargs.pop(key, None)

        kwargs['distributor_configs'] = {}
        if distributor_config:
            kwargs['distributor_configs'][constants.DISTRIBUTOR_ID] = distributor_config
        super(UpdatePuppetRepositoryCommand, self).run(**kwargs)
开发者ID:asmacdo,项目名称:pulp_puppet,代码行数:31,代码来源:cudl.py


示例6: test_empty_value

    def test_empty_value(self):
        # Setup
        args = {'key1': ''}

        # Assert that args with a '' value are converted to None
        arg_utils.convert_removed_options(args)
        self.assertTrue(args['key1'] is None)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:7,代码来源:test_client_arg_utils.py


示例7: test_non_empty_values

    def test_non_empty_values(self):
        # Setup
        args = {'key1': 'real_val', 'key2': 'another_val'}
        original_args = args.copy()

        # Test to make sure none of the keys or values are touched
        arg_utils.convert_removed_options(args)
        self.assertEqual(args, original_args)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:8,代码来源:test_client_arg_utils.py


示例8: run

    def run(self, **kwargs):
        schedule_id = kwargs.pop(OPT_SCHEDULE_ID.keyword)
        ft = kwargs.pop(OPT_FAILURE_THRESHOLD.keyword, None)
        if ft:
            kwargs['failure_threshold'] = ft

        convert_removed_options(kwargs)
        convert_boolean_arguments([OPT_ENABLED.keyword], kwargs)

        self.strategy.update_schedule(schedule_id, **kwargs)
        self.context.prompt.render_success_message(_('Successfully updated schedule'))
开发者ID:ashcrow,项目名称:pulp,代码行数:11,代码来源:schedule.py


示例9: update

    def update(self, **kwargs):
        schedule_id = kwargs.pop('schedule-id')
        ft = kwargs.pop('failure-threshold', None)
        if ft:
            kwargs['failure_threshold'] = ft

        convert_removed_options(kwargs)
        convert_boolean_arguments(['enabled'], kwargs)

        response = self.strategy.update_schedule(schedule_id, **kwargs)
        self.context.prompt.render_success_message(_('Successfully updated schedule'))
开发者ID:ehelms,项目名称:pulp,代码行数:11,代码来源:schedule.py


示例10: run

    def run(self, **kwargs):

        # -- repository metadata --
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        description = kwargs[options.OPTION_DESCRIPTION.keyword]
        notes = kwargs.pop(options.OPTION_NOTES.keyword) or {}

        # Add a note to indicate this is a Puppet repository
        notes[constants.REPO_NOTE_KEY] = constants.REPO_NOTE_PUPPET

        name = repo_id
        if options.OPTION_NAME.keyword in kwargs:
            name = kwargs[options.OPTION_NAME.keyword]

        # -- importer metadata --
        importer_config = self.parse_user_input(kwargs)
        importer_config.update(
            {constants.CONFIG_QUERIES: kwargs[OPTION_QUERIES.keyword] or kwargs[OPTION_QUERY.keyword]}
        )
        arg_utils.convert_removed_options(importer_config)

        # -- distributor metadata --
        distributor_config = {
            constants.CONFIG_SERVE_HTTP: kwargs[OPTION_HTTP.keyword],
            constants.CONFIG_SERVE_HTTPS: kwargs[OPTION_HTTPS.keyword],
        }
        arg_utils.convert_removed_options(distributor_config)
        arg_utils.convert_boolean_arguments(
            (constants.CONFIG_SERVE_HTTP, constants.CONFIG_SERVE_HTTPS), distributor_config
        )

        distributors = [
            dict(
                distributor_type=constants.DISTRIBUTOR_TYPE_ID,
                distributor_config=distributor_config,
                auto_publish=True,
                distributor_id=constants.DISTRIBUTOR_ID,
            )
        ]

        # Create the repository
        self.context.server.repo.create_and_configure(
            repo_id, name, description, notes, constants.IMPORTER_TYPE_ID, importer_config, distributors
        )

        msg = _("Successfully created repository [%(r)s]")
        self.context.prompt.render_success_message(msg % {"r": repo_id})
开发者ID:kimjohansen,项目名称:pulp_puppet,代码行数:47,代码来源:cudl.py


示例11: run

    def run(self, **kwargs):

        # Remove any entries that weren't set by the user and translate those
        # that are explicitly empty to None
        arg_utils.convert_removed_options(kwargs)

        # Gather data
        repo_id = kwargs.pop(std_options.OPTION_REPO_ID.keyword)
        description = kwargs.pop(std_options.OPTION_DESCRIPTION.keyword, None)
        display_name = kwargs.pop(std_options.OPTION_NAME.keyword, None)
        notes = kwargs.pop(std_options.OPTION_NOTES.keyword, None)

        try:
            importer_config = self.parse_user_input(kwargs)
            distributor_config = args_to_distributor_config(kwargs)
        except InvalidConfig, e:
            self.prompt.render_failure_message(str(e))
            return
开发者ID:lsjostro,项目名称:pulp_win,代码行数:18,代码来源:repo_create_update.py


示例12: run

    def run(self, **kwargs):
        # -- repository metadata --
        repo_id = kwargs.pop(options.OPTION_REPO_ID.keyword)
        description = kwargs.pop(options.OPTION_DESCRIPTION.keyword, None)
        name = kwargs.pop(options.OPTION_NAME.keyword, None)

        notes = None
        if options.OPTION_NOTES.keyword in kwargs and kwargs[options.OPTION_NOTES.keyword] is not None:
            notes = arg_utils.args_to_notes_dict(kwargs[options.OPTION_NOTES.keyword], include_none=True)

            # Make sure the note indicating it's a puppet repository is still present
            notes[constants.REPO_NOTE_KEY] = constants.REPO_NOTE_PUPPET

        # -- importer metadata --
        importer_config = {
            constants.CONFIG_FEED : kwargs.pop(OPTION_FEED.keyword, None),
            constants.CONFIG_QUERIES : kwargs.pop(OPTION_QUERY.keyword, None),
        }
        arg_utils.convert_removed_options(importer_config)

        # -- distributor metadata --
        distributor_config = {
            constants.CONFIG_SERVE_HTTP : kwargs.pop(OPTION_HTTP.keyword, None),
            constants.CONFIG_SERVE_HTTPS : kwargs.pop(OPTION_HTTPS.keyword, None),
        }
        arg_utils.convert_removed_options(distributor_config)
        arg_utils.convert_boolean_arguments((constants.CONFIG_SERVE_HTTP, constants.CONFIG_SERVE_HTTPS), distributor_config)

        distributor_configs = {constants.DISTRIBUTOR_ID : distributor_config}

        # -- server update --
        response = self.context.server.repo.update_repo_and_plugins(repo_id, name,
                        description, notes, importer_config, distributor_configs)

        if not response.is_async():
            msg = _('Repository [%(r)s] successfully updated')
            self.context.prompt.render_success_message(msg % {'r' : repo_id})
        else:
            d = _('Repository update postponed due to another operation. Progress '
                'on this task can be viewed using the commands under "repo tasks".')
            self.context.prompt.render_paragraph(d, tag='postponed')
            self.context.prompt.render_reasons(response.response_body.reasons)
开发者ID:ehelms,项目名称:pulp,代码行数:42,代码来源:repo.py


示例13: run

    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        description = kwargs[options.OPTION_DESCRIPTION.keyword]
        notes = kwargs.pop(options.OPTION_NOTES.keyword) or {}

        # Add a note to indicate this is a Deb repository
        notes[constants.REPO_NOTE_KEY] = constants.REPO_NOTE

        name = repo_id
        if options.OPTION_NAME.keyword in kwargs:
            name = kwargs[options.OPTION_NAME.keyword]

        # -- importer metadata --
        importer_config = {
            constants.CONFIG_URL: kwargs[OPTION_URL.keyword],
            constants.CONFIG_DIST: kwargs[OPTION_DIST.keyword],
            constants.CONFIG_COMPONENT: kwargs[OPTION_COMPONENT.keyword],
            constants.CONFIG_ARCH: kwargs[OPTION_ARCH.keyword],
            constants.CONFIG_QUERIES: kwargs[OPTION_QUERY.keyword],
        }
        arg_utils.convert_removed_options(importer_config)

        # -- distributor metadata --
        distributor_config = {
            constants.CONFIG_SERVE_INSECURE: kwargs[OPTION_INSECURE.keyword],
        }

        arg_utils.convert_removed_options(distributor_config)
        arg_utils.convert_boolean_arguments((constants.CONFIG_SERVE_INSECURE), distributor_config)

        distributors = [
            dict(distributor_type=constants.DISTRIBUTOR_TYPE_ID, distributor_config=distributor_config,
                 auto_publish=True, distributor_id=constants.DISTRIBUTOR_ID)
        ]

        # Create the repository
        self.context.server.repo.create_and_configure(repo_id, name, description,
            notes, constants.IMPORTER_TYPE_ID, importer_config)
        #notes, constants.IMPORTER_TYPE_ID, importer_config, distributors)
        msg = _('Successfully created repository [%(r)s]')
        self.context.prompt.render_success_message(msg % {'r': repo_id})
开发者ID:collectivemedia,项目名称:pulp_deb,代码行数:41,代码来源:cudl.py


示例14: run

    def run(self, **user_input):
        """
        Run the repository creation.
        """
        # Turn missing options to None
        arg_utils.convert_removed_options(user_input)

        repo_id = user_input.pop(std_options.OPTION_REPO_ID.keyword)
        description = user_input.pop(std_options.OPTION_DESCRIPTION.keyword, None)
        display_name = user_input.pop(std_options.OPTION_NAME.keyword, None)
        notes = user_input.pop(std_options.OPTION_NOTES.keyword, None) or {}

        # Mark this as an ISO repository
        notes[pulp_constants.REPO_NOTE_TYPE_KEY] = constants.REPO_NOTE_ISO

        # Build the importer and distributor configs
        try:
            importer_config = self.parse_user_input(user_input)
            distributor_config = self._parse_distributor_config(user_input)
        except arg_utils.InvalidConfig, e:
            self.prompt.render_failure_message(str(e), tag='create-failed')
            return os.EX_DATAERR
开发者ID:asmacdo,项目名称:pulp_rpm,代码行数:22,代码来源:create_update.py


示例15: run

    def run(self, **kwargs):

        # -- repository metadata --
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        description = kwargs[options.OPTION_DESCRIPTION.keyword]
        notes = {}
        if kwargs[options.OPTION_NOTES.keyword]:
            notes = arg_utils.args_to_notes_dict(kwargs[options.OPTION_NOTES.keyword], include_none=True)
        name = repo_id
        if options.OPTION_NAME.keyword in kwargs:
            name = kwargs[options.OPTION_NAME.keyword]

        # Add a note to indicate this is a Puppet repository
        notes[constants.REPO_NOTE_KEY] = constants.REPO_NOTE_PUPPET

        # -- importer metadata --
        importer_config = {
            constants.CONFIG_FEED : kwargs[OPTION_FEED.keyword],
            constants.CONFIG_QUERIES : kwargs[OPTION_QUERY.keyword],
        }
        arg_utils.convert_removed_options(importer_config)

        # -- distributor metadata --
        distributor_config = {
            constants.CONFIG_SERVE_HTTP : kwargs[OPTION_HTTP.keyword],
            constants.CONFIG_SERVE_HTTPS : kwargs[OPTION_HTTPS.keyword],
        }
        arg_utils.convert_removed_options(distributor_config)
        arg_utils.convert_boolean_arguments((constants.CONFIG_SERVE_HTTP, constants.CONFIG_SERVE_HTTPS), distributor_config)

        distributors = [(constants.DISTRIBUTOR_TYPE_ID, distributor_config, True, constants.DISTRIBUTOR_ID)]

        # Create the repository
        self.context.server.repo.create_and_configure(repo_id, name, description,
            notes, constants.IMPORTER_TYPE_ID, importer_config, distributors)

        msg = _('Successfully created repository [%(r)s]')
        self.context.prompt.render_success_message(msg % {'r' : repo_id})
开发者ID:jlsherrill,项目名称:pulp,代码行数:38,代码来源:repo.py


示例16: _prep_config

def _prep_config(kwargs, plugin_config_keys):
    """
    Performs common initialization for both importer and distributor config
    parsing. The common conversion includes:

    * Create a base config dict pulling the given plugin_config_keys from the
      user-specified arguments
    * Translate the client-side argument names into the plugin expected keys
    * Strip out any None values which means the user did not specify the
      argument in the call
    * Convert any empty strings into None which represents the user removing
      the config value

    @param plugin_config_keys: one of the *_CONFIG_KEYS constants
    @return: dictionary to use as the basis for the config
    """

    # User-specified flags use hyphens but the importer/distributor want
    # underscores, so do a quick translation here before anything else.
    for k in kwargs.keys():
        v = kwargs.pop(k)
        new_key = k.replace('-', '_')
        kwargs[new_key] = v

    # Populate the plugin config with the plugin-relevant keys in the user args
    user_arg_keys = [k[1] for k in plugin_config_keys]
    plugin_config = dict([(k, v) for k, v in kwargs.items() if k in user_arg_keys])

    # Simple name translations
    for plugin_key, cli_key in plugin_config_keys:
        plugin_config[plugin_key] = plugin_config.pop(cli_key, None)

    # Apply option removal conventions
    convert_removed_options(plugin_config)

    return plugin_config
开发者ID:ehelms,项目名称:pulp,代码行数:36,代码来源:pulp_cli.py


示例17: run

    def run(self, **kwargs):
        arg_utils.convert_removed_options(kwargs)

        importer_config = self.parse_user_input(kwargs)

        name = kwargs.pop(OPT_UPSTREAM_NAME.keyword, None)
        if name is not None:
            importer_config[constants.CONFIG_KEY_UPSTREAM_NAME] = name

        if importer_config:
            kwargs['importer_config'] = importer_config

        # Update distributor configuration
        web_config = {}
        export_config = {}
        value = kwargs.pop(OPT_PROTECTED.keyword, None)
        if value is not None:
            web_config[constants.CONFIG_KEY_PROTECTED] = value
            export_config[constants.CONFIG_KEY_PROTECTED] = value

        value = kwargs.pop(OPT_REDIRECT_URL.keyword, None)
        if value is not None:
            web_config[constants.CONFIG_KEY_REDIRECT_URL] = value
            export_config[constants.CONFIG_KEY_REDIRECT_URL] = value

        value = kwargs.pop(OPT_REPO_REGISTRY_ID.keyword, None)
        if value is not None:
            web_config[constants.CONFIG_KEY_REPO_REGISTRY_ID] = value
            export_config[constants.CONFIG_KEY_REPO_REGISTRY_ID] = value

        value = kwargs.pop(OPT_AUTO_PUBLISH.keyword, None)
        if value is not None:
            web_config['auto_publish'] = value

        if web_config or export_config:
            kwargs['distributor_configs'] = {}

        if web_config:
            kwargs['distributor_configs'][constants.CLI_WEB_DISTRIBUTOR_ID] = web_config

        if export_config:
            kwargs['distributor_configs'][constants.CLI_EXPORT_DISTRIBUTOR_ID] = export_config

        # Update Tags
        repo_id = kwargs.get(OPTION_REPO_ID.keyword)
        response = self.context.server.repo.repository(repo_id).response_body
        scratchpad = response.get(u'scratchpad', {})
        image_tags = scratchpad.get(u'tags', [])

        user_tags = kwargs.get(OPTION_TAG.keyword)
        if user_tags:
            user_tags = kwargs.pop(OPTION_TAG.keyword)
            for tag, image_id in user_tags:
                if len(image_id) < 6:
                    msg = _('The image id, (%s), must be at least 6 characters.')
                    self.prompt.render_failure_message(msg % image_id)
                    return

            # Ensure the specified images exist in the repo
            images_requested = set([image_id for tag, image_id in user_tags])
            images = ['^%s' % image_id for image_id in images_requested]
            image_regex = '|'.join(images)
            search_criteria = {
                'type_ids': constants.IMAGE_TYPE_ID,
                'match': [['image_id', image_regex]],
                'fields': ['image_id']
            }

            response = self.context.server.repo_unit.search(repo_id, **search_criteria).\
                response_body
            if len(response) != len(images):
                images_found = set([x[u'metadata'][u'image_id'] for x in response])
                missing_images = images_requested.difference(images_found)
                msg = _('Unable to create tag in repository. The following image(s) do not '
                        'exist in the repository: %s.')
                self.prompt.render_failure_message(msg % ', '.join(missing_images))
                return

            # Get the full image id from the returned values and save in tags_to_update dictionary
            tags_to_update = {}
            for image in response:
                found_image_id = image[u'metadata'][u'image_id']
                for tag, image_id in user_tags:
                    if found_image_id.startswith(image_id):
                        tags_to_update[tag] = found_image_id

            # Create a list of tag dictionaries that can be saved on the repo scratchpad
            # using the original tags and new tags specified by the user
            image_tags = tags.generate_updated_tags(scratchpad, tags_to_update)
            scratchpad[u'tags'] = image_tags
            kwargs[u'scratchpad'] = scratchpad

        remove_tags = kwargs.get(OPTION_REMOVE_TAG.keyword)
        if remove_tags:
            kwargs.pop(OPTION_REMOVE_TAG.keyword)
            for tag in remove_tags:
                # For each tag in remove_tags, remove the respective tag dictionary
                # for matching tag.
                for image_tag in image_tags[:]:
                    if tag == image_tag[constants.IMAGE_TAG_KEY]:
#.........这里部分代码省略.........
开发者ID:shubham90,项目名称:pulp_docker,代码行数:101,代码来源:cudl.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python importer_config.ImporterConfigMixin类代码示例发布时间:2022-05-25
下一篇:
Python arg_utils.args_to_notes_dict函数代码示例发布时间: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