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


Python arg_utils.args_to_notes_dict函数代码示例

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


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