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


Python arg_utils.convert_removed_options函数代码示例

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


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


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