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

Python arg_utils.args_to_notes_dict函数代码示例

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

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



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

示例1: create

    def create(self, **kwargs):

        # All of the options will be present, even if the user didn't specify
        # them. Their values will be None, which the yum importer is set up
        # to handle.

        # Gather data
        repo_id = kwargs.pop('repo-id')
        description = kwargs.pop('description', None)
        display_name = kwargs.pop('display-name', None)
        auto_publish = kwargs.pop('auto-publish', None)

        if auto_publish:
            auto_publish = arg_to_bool(auto_publish)
            if auto_publish:
                self.context.prompt.render_failure_message(_('Value for auto-publish must be either true or false'))
                return

        try:
            notes = None
            if 'note' in kwargs and kwargs['note'] is not None:
                notes = args_to_notes_dict(kwargs['note'], include_none=False)
            importer_config = args_to_importer_config(kwargs)
            distributor_config = args_to_distributor_config(kwargs)
        except InvalidConfig, e:
            self.context.prompt.render_failure_message(e[0])
            return
开发者ID:ehelms,项目名称:pulp,代码行数:27,代码来源:pulp_cli.py


示例2: test_dict_arg

    def test_dict_arg(self):
        """
        Tests to make sure that attempting to parse a dict returns the dict
        """
        # Setup
        test_dict = {'key': 'value', 'key2': 'value2'}

        # Test
        result = arg_utils.args_to_notes_dict(test_dict)
        self.assertTrue(test_dict is result)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:10,代码来源:test_client_arg_utils.py


示例3: test_include_none_false

    def test_include_none_false(self):
        """
        Tests to make sure keys with null values are not returned when include_none=False
        """
        # Setup
        test_list = ['key=value', 'key2=', 'key3=""']

        # Test
        result = arg_utils.args_to_notes_dict(test_list, include_none=False)
        self.assertTrue('key' in result)
        self.assertEqual(result['key'], 'value')
        self.assertFalse('key2' in result)
        self.assertFalse('key3' in result)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:13,代码来源:test_client_arg_utils.py


示例4: create

    def create(self, **kwargs):

        # Collect input
        id = kwargs['repo-id']
        name = id
        if 'display-name' in kwargs:
            name = kwargs['display-name']
        description = kwargs['description']
        notes = arg_utils.args_to_notes_dict(kwargs['note'], include_none=True)

        # Call the server
        self.context.server.repo.create(id, name, description, notes)
        self.prompt.render_success_message('Repository [%s] successfully created' % id)
开发者ID:stpierre,项目名称:pulp,代码行数:13,代码来源:pulp_cli.py


示例5: run

    def run(self, **kwargs):
        # Collect input
        id = kwargs[OPTION_REPO_ID.keyword]
        name = id
        if OPTION_NAME.keyword in kwargs:
            name = kwargs[OPTION_NAME.keyword]
        description = kwargs[OPTION_DESCRIPTION.keyword]
        notes = arg_utils.args_to_notes_dict(kwargs[OPTION_NOTES.keyword], include_none=True)

        # Call the server
        self.context.server.repo.create(id, name, description, notes)
        msg = _('Repository [%(r)s] successfully created')
        self.prompt.render_success_message(msg % {'r' : id})
开发者ID:domcleal,项目名称:pulp,代码行数:13,代码来源:cudl.py


示例6: update

    def update(self, **kwargs):
        # Assemble the delta for all options that were passed in
        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        delta.pop('group-id') # not needed in the delta

        if delta.pop('note', None) is not None:
            delta['notes'] = arg_utils.args_to_notes_dict(kwargs['note'], include_none=True)
        try:
            self.context.server.repo_group.update(kwargs['group-id'], delta)
            self.prompt.render_success_message(
                'Repo group [%s] successfully updated' % kwargs['group-id'])
        except NotFoundException:
            self.prompt.write(
                'Repo group [%s] does not exist on the server' % kwargs['group-id'], tag='not-found')
开发者ID:stpierre,项目名称:pulp,代码行数:14,代码来源:pulp_cli.py


示例7: run

    def run(self, **kwargs):
        # Assemble the delta for all options that were passed in
        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        delta.pop(OPTION_GROUP_ID.keyword) # not needed in the delta

        if delta.pop(OPTION_NOTES.keyword, None) is not None:
            delta['notes'] = arg_utils.args_to_notes_dict(kwargs[OPTION_NOTES.keyword], include_none=True)
        try:
            self.context.server.repo_group.update(kwargs[OPTION_GROUP_ID.keyword], delta)
            msg = 'Repo group [%(g)s] successfully updated'
            self.prompt.render_success_message(msg % {'g' : kwargs['group-id']})
        except NotFoundException:
            msg = 'Repo group [%(g)s] does not exist on the server'
            self.prompt.write(msg % {'g' : kwargs['group-id']}, tag='not-found')
开发者ID:ehelms,项目名称:pulp,代码行数:14,代码来源:group.py


示例8: create

    def create(self, **kwargs):
        # Collect input
        consumer_group_id = kwargs['consumer-group-id']
        name = consumer_group_id
        if 'display-name' in kwargs:
            name = kwargs['display-name']
        description = kwargs['description']
        notes = kwargs.get('notes', None)
        if notes:
            notes = arg_utils.args_to_notes_dict(notes, include_none=True)

        # Call the server
        self.context.server.consumer_group.create(consumer_group_id, name, description, notes)
        self.prompt.render_success_message(
            'Consumer Group [%s] successfully created' % consumer_group_id)
开发者ID:ehelms,项目名称:pulp,代码行数:15,代码来源:pulp_cli.py


示例9: update

    def update(self, **kwargs):

        # Assemble the delta for all options that were passed in
        consumer_id = load_consumer_id(self.context)
        if not consumer_id:
            self.prompt.render_failure_message("This consumer is not registered to the Pulp server.")
            return
        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        if 'note' in delta.keys():
            if delta['note']:
                delta['notes'] = args_to_notes_dict(kwargs['note'], include_none=False)
            delta.pop('note')

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.prompt.render_success_message('Consumer [%s] successfully updated' % consumer_id)
        except NotFoundException:
            self.prompt.write('Consumer [%s] does not exist on the server' % consumer_id, tag='not-found')
开发者ID:ehelms,项目名称:pulp,代码行数:18,代码来源:pulp_cli.py


示例10: update

    def update(self, **kwargs):

        # Assemble the delta for all options that were passed in
        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        delta.pop(OPTION_CONSUMER_ID.keyword) # not needed in the delta
        if OPTION_NOTES.keyword in delta.keys():
            delta['notes'] = args_to_notes_dict(delta['note'])
            delta.pop(OPTION_NOTES.keyword)
        if OPTION_NAME.keyword in delta:
            v = delta.pop(OPTION_NAME.keyword)
            key = OPTION_NAME.keyword.replace('-', '_')
            delta[key] = v

        try:
            self.context.server.consumer.update(kwargs[OPTION_CONSUMER_ID.keyword], delta)
            self.prompt.render_success_message('Consumer [%s] successfully updated' % kwargs[OPTION_CONSUMER_ID.keyword])
        except NotFoundException:
            self.prompt.write('Consumer [%s] does not exist on the server' % kwargs[OPTION_CONSUMER_ID.keyword], tag='not-found')
开发者ID:jessegonzalez,项目名称:pulp_rpm,代码行数:18,代码来源:basics.py


示例11: register

    def register(self, **kwargs):

        # Get consumer id
        id = kwargs["consumer-id"]

        # Check if this consumer is already registered
        existing_consumer = load_consumer_id(self.context)
        if existing_consumer:
            m = (
                "This system has already been registered as a consumer. Please "
                "use the unregister command to remove the consumer before attempting "
                "to reregister."
            )
            self.prompt.render_failure_message(_(m))
            return

        # Get other consumer parameters
        name = id
        if "display-name" in kwargs:
            name = kwargs["display-name"]
        description = kwargs["description"]
        notes = None
        if "note" in kwargs.keys():
            if kwargs["note"]:
                notes = args_to_notes_dict(kwargs["note"], include_none=False)

        # Check write permissions to cert directory
        id_cert_dir = self.context.config["filesystem"]["id_cert_dir"]
        if not os.access(id_cert_dir, os.W_OK):
            msg = _("Write permission is required for %(d)s to perform this operation.")
            self.prompt.render_failure_message(msg % {"d": id_cert_dir})
            return os.EX_NOPERM

        # Call the server
        consumer = self.context.server.consumer.register(id, name, description, notes).response_body

        # Write consumer cert
        id_cert_name = self.context.config["filesystem"]["id_cert_filename"]
        cert_filename = os.path.join(id_cert_dir, id_cert_name)
        f = open(cert_filename, "w")
        f.write(consumer["certificate"])
        f.close()

        self.prompt.render_success_message("Consumer [%s] successfully registered" % id)
开发者ID:pieska,项目名称:pulp,代码行数:44,代码来源:pulp_cli.py


示例12: parse_notes

def parse_notes(value):
    """
    Returns a value suitable to send to the server for a notes value on a
    repository. The given value will actually be a list of values regardless
    of whether or not the user specified multiple notes.

    :param value: list of user entered values or empty list if unspecified
    :type  value: list
    :return: dictionary representation of all user entered notes
    :rtype: dict
    """

    if value is None:
        return None

    try:
        return arg_utils.args_to_notes_dict(value)
    except arg_utils.InvalidConfig:
        raise ValueError(_('invalid syntax for specifying notes'))
开发者ID:ryanschneider,项目名称:pulp,代码行数:19,代码来源:parsers.py


示例13: run

    def run(self, **kwargs):
        # Assemble the delta for all options that were passed in
        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        delta.pop(OPTION_REPO_ID.keyword) # not needed in the delta

        # Translate the argument to key name
        if delta.pop(OPTION_NAME.keyword, None) is not None:
            delta['display_name'] = kwargs[OPTION_NAME.keyword]

        if delta.pop(OPTION_NOTES.keyword, None) is not None:
            delta['notes'] = arg_utils.args_to_notes_dict(kwargs[OPTION_NOTES.keyword], include_none=True)

        try:
            self.context.server.repo.update(kwargs[OPTION_REPO_ID.keyword], delta)
            msg = _('Repository [%(r)s] successfully updated')
            self.prompt.render_success_message(msg % {'r' : kwargs[OPTION_REPO_ID.keyword]})
        except NotFoundException:
            msg = _('Repository [%(r)s] does not exist on the server')
            self.prompt.write(msg % {'r' : kwargs[OPTION_REPO_ID.keyword]}, tag='not-found')
开发者ID:jlsherrill,项目名称:pulp,代码行数:19,代码来源:cudl.py


示例14: register

    def register(self, **kwargs):

        # Get consumer id
        id = kwargs['consumer-id']

        # Check if this consumer is already registered
        existing_consumer = load_consumer_id(self.context)
        if existing_consumer:
            m = _('This system has already been registered as a consumer. Please '
                  'use the unregister command to remove the consumer before attempting '
                  'to re-register.')
            self.prompt.render_failure_message(m)
            return

        # Get other consumer parameters
        name = id
        if 'display-name' in kwargs:
            name = kwargs['display-name']
        description = kwargs['description']
        notes = None
        if 'note' in kwargs.keys():
            if kwargs['note']:
                notes = args_to_notes_dict(kwargs['note'], include_none=False)

        # Check write permissions to cert directory
        id_cert_dir = self.context.config['filesystem']['id_cert_dir']
        if not os.access(id_cert_dir, os.W_OK):
            msg = _("Write permission is required for %(d)s to perform this operation.")
            self.prompt.render_failure_message(msg % {'d': id_cert_dir})
            return exceptions.CODE_PERMISSIONS_EXCEPTION

        # Call the server
        consumer = self.context.server.consumer.register(id, name, description, notes).response_body

        # Write consumer cert
        id_cert_name = self.context.config['filesystem']['id_cert_filename']
        cert_filename = os.path.join(id_cert_dir, id_cert_name)
        f = open(cert_filename, 'w')
        f.write(consumer['certificate'])
        f.close()

        self.prompt.render_success_message('Consumer [%s] successfully registered' % id)
开发者ID:cliffy94,项目名称:pulp,代码行数:42,代码来源:pulp_cli.py


示例15: 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


示例16: update

    def update(self, **kwargs):
        consumer_id = load_consumer_id(self.context)
        if not consumer_id:
            self.prompt.render_failure_message("This consumer is not registered to the Pulp "
                                               "server.")
            return

        delta = dict([(k, v) for k, v in kwargs.items() if v is not None])
        if 'note' in delta.keys():
            if delta['note']:
                delta['notes'] = args_to_notes_dict(kwargs['note'], include_none=False)
            delta.pop('note')
        # convert display-name to display_name
        key = 'display-name'
        if key in delta:
            v = delta.pop(key)
            key = key.replace('-', '_')
            delta[key] = v

        if kwargs.get(OPTION_EXCHANGE_KEYS.keyword):
            path = self.context.config['authentication']['rsa_pub']
            fp = open(path)
            try:
                delta['rsa_pub'] = fp.read()
            finally:
                fp.close()

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.prompt.render_success_message('Consumer [%s] successfully updated' % consumer_id)
            if not kwargs.get(OPTION_EXCHANGE_KEYS.keyword):
                return
            try:
                update_server_key(self.context.config)
            except Exception, e:
                msg = _('Download server RSA key failed [%(e)s]' % {'e': e})
                self.prompt.render_failure_message(msg)
        except NotFoundException:
            self.prompt.write('Consumer [%s] does not exist on the server' % consumer_id,
                              tag='not-found')
开发者ID:credativ,项目名称:pulp,代码行数:40,代码来源:cli.py


示例17: 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


示例18: update

    def update(self, **kwargs):

        # Gather data
        repo_id = kwargs.pop('repo-id')
        description = kwargs.pop('description', None)
        display_name = kwargs.pop('display-name', None)
        auto_publish = kwargs.pop('auto-publish', None)

        if auto_publish:
            auto_publish = arg_to_bool(auto_publish)
            if auto_publish is None:
                self.context.prompt.render_failure_message(_('Value for auto-publish must be either true or false'))
                return

        try:
            notes = None
            if 'note' in kwargs and kwargs['note'] is not None:
                notes = args_to_notes_dict(kwargs['note'], include_none=True)

            importer_config = args_to_importer_config(kwargs)
        except InvalidConfig, e:
            self.context.prompt.render_failure_message(e[0])
            return
开发者ID:ehelms,项目名称:pulp,代码行数:23,代码来源:pulp_cli.py


示例19: run

    def run(self, **kwargs):
        consumer_id = self.get_consumer_id(kwargs)
        delta = dict((k, v) for k, v in kwargs.items() if v is not None)

        if OPTION_NOTES.keyword in delta:
            notes_args = delta.pop(OPTION_NOTES.keyword)
            delta["notes"] = args_to_notes_dict(notes_args)

        if OPTION_NAME.keyword in delta:
            name = delta.pop(OPTION_NAME.keyword)
            delta[OPTION_NAME.keyword.replace("-", "_")] = name

        try:
            self.context.server.consumer.update(consumer_id, delta)

        except NotFoundException:
            msg = _("Consumer [ %(c)s ] does not exist on server") % {"c": consumer_id}
            self.context.prompt.render_failure_message(msg)
            return os.EX_DATAERR

        else:
            msg = _("Consumer [ %(c)s ] successfully updated") % {"c": consumer_id}
            self.context.prompt.render_success_message(msg)
开发者ID:slagle,项目名称:pulp,代码行数:23,代码来源:manage.py


示例20: _parse_basic_options

    def _parse_basic_options(self, kwargs):
        """
        Parse the options known by this class

        :param kwargs:  user input as provided by okaara
        :type  kwargs:  dict

        :return:    tuple of repo_id, name, description, notes
        :rtype:     tuple
        """

        # Collect input
        repo_id = kwargs[OPTION_REPO_ID.keyword]
        name = repo_id
        if OPTION_NAME.keyword in kwargs:
            name = kwargs[OPTION_NAME.keyword]
        description = kwargs[OPTION_DESCRIPTION.keyword]
        if kwargs[OPTION_NOTES.keyword]:
            notes = arg_utils.args_to_notes_dict(kwargs[OPTION_NOTES.keyword], include_none=True)
        else:
            notes = {}
        notes.update(self.default_notes)

        return repo_id, name, description, notes
开发者ID:alanoe,项目名称:pulp,代码行数:24,代码来源:cudl.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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