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


Python OrderedDict.values方法代码示例

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


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

示例1: handle

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a component name or ID.")

        identifier = args[0]
        if identifier.isdigit():
            try:
                component = Component.objects.get(id=int(identifier))
            except Component.DoesNotExist:
                raise CommandError('No component found with ID %s.' %
                                   identifier)
        else:
            try:
                component = Component.objects.get(name=identifier)
            except Component.DoesNotExist:
                raise CommandError('No component found named %s.' % identifier)

        kv = OrderedDict(
            [
                ('id', component.id),
                ('name', component.name),
                ('base url', component.base_url),
                ('ui url', component.url),
                ('token', component.auth_token),
                ('token created', component.auth_token_created),
                ('token expires', component.auth_token_expires),
            ])

        utils.pprint_table(self.stdout, [kv.values()], kv.keys(),
                           options["output_format"], vertical=True)

        services = component.service_set.all()

        service_data = []
        for service in services:
            service_data.append((service.id, service.name, service.type))

        if service_data:
            self.stdout.write('\n')
            labels = ('id', 'name', 'type')
            utils.pprint_table(self.stdout, service_data, labels,
                               options["output_format"],
                               title='Registered services')
开发者ID:antonis-m,项目名称:synnefo,代码行数:45,代码来源:component-show.py

示例2: handle

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please profile name")

        try:
            profile = Profile.objects.get(name=args[0])
        except Profile.DoesNotExist:
            raise CommandError("Profile does not exist")

        kv = OrderedDict(
            [
                ('id', profile.id),
                ('is active', str(profile.active)),
                ('name', profile.name),
                ('is exclusive', profile.is_exclusive),
                ('policies', profile.policies),
                ('groups', profile.groups.all()),
                ('users', profile.users.all())
            ])

        utils.pprint_table(self.stdout, [kv.values()], kv.keys(),
                           options["output_format"], vertical=True)
开发者ID:antonis-m,项目名称:synnefo,代码行数:24,代码来源:authpolicy-show.py

示例3: handle

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a service name or ID.")

        identifier = args[0]
        if identifier.isdigit():
            try:
                service = Service.objects.get(id=int(identifier))
            except Service.DoesNotExist:
                raise CommandError('No service found with ID %s.' % identifier)
        else:
            try:
                service = Service.objects.get(name=identifier)
            except Service.DoesNotExist:
                raise CommandError('No service found named %s.' % identifier)

        kv = OrderedDict(
            [
                ('id', service.id),
                ('name', service.name),
                ('component', service.component),
                ('type', service.type),
            ])

        utils.pprint_table(self.stdout, [kv.values()], kv.keys(),
                           options["output_format"], vertical=True)

        self.stdout.write('\n')
        endpoint_data = EndpointData.objects.filter(endpoint__service=service)
        data = []
        for ed in endpoint_data:
            data.append((ed.endpoint_id, ed.key, ed.value))

        labels = ('endpoint', 'key', 'value')
        utils.pprint_table(self.stdout, data, labels,
                           options["output_format"],
                           title='Endpoints')
开发者ID:antonis-m,项目名称:synnefo,代码行数:39,代码来源:service-show.py

示例4: AMQPPukaClient

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]

#.........这里部分代码省略.........
                                            callback=callback)

        if self.confirms:
            self.unacked[promise] = (exchange, routing_key, body)

        return promise

    def handle_publisher_confirm(self, promise, result):
        """Handle publisher confirmation message.

        Callback function which handles publisher confirmation by removing
        the promise (and message) from 'unacked' messages.

        """
        msg = self.unacked.pop(promise, None)
        if msg is None:
            self.log.warning("Received publisher confirmation for"
                             " unknown promise '%s'", promise)

    @reconnect_decorator
    def flush_buffer(self):
        while self.client.needs_write():
            self.client.on_write()

    @reconnect_decorator
    def get_confirms(self):
        """Wait for all publisher confirmations."""
        while self.unacked:
            self.client.wait(self.unacked.keys())

    @reconnect_decorator
    def _resend_unacked_messages(self):
        """Resend unacked messages in case of a connection failure."""
        msgs = self.unacked.values()
        self.unacked.clear()
        for exchange, routing_key, body in msgs:
            self.log.debug('Resending message %s' % body)
            self.basic_publish(exchange, routing_key, body)

    @reconnect_decorator
    def _resend_unsend_messages(self):
        """Resend unsend messages in case of a connection failure."""
        for body in self.unsend.keys():
            (exchange, routing_key) = self.unsend[body]
            self.basic_publish(exchange, routing_key, body)
            self.unsend.pop(body)

    @reconnect_decorator
    def basic_consume(self, queue, callback, no_ack=False, prefetch_count=0):
        """Consume from a queue.

        @type queue: string or list of strings
        @param queue: the name or list of names from the queues to consume
        @type callback: function
        @param callback: the callback function to run when a message arrives

        """
        self.log.debug("Consume from queue '%s'", queue)
        # Store the queues and the callback
        self.consumers[queue] = callback

        def handle_delivery(promise, msg):
            """Hide promises and messages without body"""
            if 'body' in msg:
                callback(self, msg)
            else:
开发者ID:AthinaB,项目名称:synnefo,代码行数:70,代码来源:amqp_puka.py

示例5: handle

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a user ID or email")

        identifier = args[0]
        if identifier.isdigit():
            users = AstakosUser.objects.filter(id=int(identifier))
        else:
            try:
                uuid.UUID(identifier)
            except:
                users = AstakosUser.objects.filter(email__iexact=identifier)
            else:
                users = AstakosUser.objects.filter(uuid=identifier)
        if users.count() == 0:
            field = "id" if identifier.isdigit() else "email"
            msg = "Unknown user with %s '%s'" % (field, identifier)
            raise CommandError(msg)

        for user in users:
            kv = OrderedDict(
                [
                    ("id", user.id),
                    ("uuid", user.uuid),
                    ("status", user.status_display),
                    ("email", user.email),
                    ("first name", user.first_name),
                    ("last name", user.last_name),
                    ("admin", user.is_superuser),
                    ("last login", user.last_login),
                    ("date joined", user.date_joined),
                    ("last update", user.updated),
                    # ('token', user.auth_token),
                    ("token expiration", user.auth_token_expires),
                    ("providers", user.auth_providers_display),
                    ("groups", [elem.name for elem in user.groups.all()]),
                    ("permissions", [elem.codename for elem in user.user_permissions.all()]),
                    ("group permissions", user.get_group_permissions()),
                    ("email_verified", user.email_verified),
                    ("moderated", user.moderated),
                    ("rejected", user.is_rejected),
                    ("active", user.is_active),
                    ("username", user.username),
                    ("activation_sent_date", user.activation_sent),
                    ("last_login_details", user.last_login_info_display),
                ]
            )

            if get_latest_terms():
                has_signed_terms = user.signed_terms
                kv["has_signed_terms"] = has_signed_terms
                if has_signed_terms:
                    kv["date_signed_terms"] = user.date_signed_terms

            utils.pprint_table(self.stdout, [kv.values()], kv.keys(), options["output_format"], vertical=True)

            if options["list_quotas"] and user.is_accepted():
                unit_style = options["unit_style"]
                check_style(unit_style)

                quotas = get_user_quotas(user)
                if quotas:
                    self.stdout.write("\n")
                    print_data, labels = show_user_quotas(quotas, style=unit_style)
                    utils.pprint_table(self.stdout, print_data, labels, options["output_format"], title="User Quota")

            if options["list_projects"]:
                print_data, labels = ownerships(user)
                if print_data:
                    self.stdout.write("\n")
                    utils.pprint_table(
                        self.stdout, print_data, labels, options["output_format"], title="Owned Projects"
                    )

                print_data, labels = memberships(user)
                if print_data:
                    self.stdout.write("\n")
                    utils.pprint_table(
                        self.stdout, print_data, labels, options["output_format"], title="Project Memberships"
                    )
开发者ID:konsP,项目名称:synnefo,代码行数:82,代码来源:user-show.py

示例6: AMQPHaighaClient

# 需要导入模块: from synnefo.lib.ordereddict import OrderedDict [as 别名]
# 或者: from synnefo.lib.ordereddict.OrderedDict import values [as 别名]

#.........这里部分代码省略.........

        self.channel.queue.declare(queue, durable=True, exclusive=exclusive,
                                   auto_delete=False, arguments=arguments)

    def queue_bind(self, queue, exchange, routing_key):
        logger.info('Binding queue %s to exchange %s with key %s', queue,
                    exchange, routing_key)
        self.channel.queue.bind(queue=queue, exchange=exchange,
                                routing_key=routing_key)

    def _confirm_select(self):
        logger.info('Setting channel to confirm mode')
        self.channel.confirm.select()
        self.channel.basic.set_ack_listener(self._ack_received)
        self.channel.basic.set_nack_listener(self._nack_received)

    @reconnect_decorator
    def basic_publish(self, exchange, routing_key, body):
        msg = Message(body, delivery_mode=2)
        mid = self.channel.basic.publish(msg, exchange, routing_key)
        if self.confirms:
            self.unacked[mid] = (exchange, routing_key, body)
            if len(self.unacked) > self.confirm_buffer:
                self.get_confirms()

        logger.debug('Published message %s with id %s', body, mid)

    @reconnect_decorator
    def get_confirms(self):
        self.connection.read_frames()

    @reconnect_decorator
    def _resend_unacked_messages(self):
        msgs = self.unacked.values()
        self.unacked.clear()
        for exchange, routing_key, body in msgs:
            logger.debug('Resending message %s', body)
            self.basic_publish(exchange, routing_key, body)

    @reconnect_decorator
    def _ack_received(self, mid):
        print mid
        logger.debug('Received ACK for message with id %s', mid)
        self.unacked.pop(mid)

    @reconnect_decorator
    def _nack_received(self, mid):
        logger.error('Received NACK for message with id %s. Retrying.', mid)
        (exchange, routing_key, body) = self.unacked[mid]
        self.basic_publish(exchange, routing_key, body)

    def basic_consume(self, queue, callback, no_ack=False, exclusive=False):
        """Consume from a queue.

        @type queue: string or list of strings
        @param queue: the name or list of names from the queues to consume
        @type callback: function
        @param callback: the callback function to run when a message arrives

        """

        self.consumers[queue] = callback
        self.channel.basic.consume(queue, consumer=callback, no_ack=no_ack,
                                   exclusive=exclusive)

    @reconnect_decorator
开发者ID:grnet,项目名称:synnefo,代码行数:70,代码来源:amqp_haigha.py


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