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


Python resultset.ResultSet类代码示例

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


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

示例1: _paginate_resultset

def _paginate_resultset(result, function_ref, *argv, **kwargs):
    """
    Paginate through a query that returns a :py:class:`boto.resultset.ResultSet`
    object, and return the combined result.

    All function calls are passed through
    :py:func:`~.invoke_with_throttling_retries`.

    :param result: the first ResultSet from the query
    :type result: :py:class:`boto.resultset.ResultSet`
    :param function_ref: the function to call
    :type function_ref: function
    :param argv: the parameters to pass to the function
    :type argv: tuple
    :param kwargs: keyword arguments to pass to the function
      (:py:func:`~.invoke_with_throttling_retries`)
    :type kwargs: dict
    """
    logger.debug("Iterating all ResultSets for query of %s", function_ref)
    # we don't want any markers in the final result
    final_result = ResultSet()
    final_result.extend(result)
    while hasattr(result, 'next_token') and result.next_token is not None:
        logger.debug("Getting next response set; next_token=%s",
                     result.next_token)
        next_kwargs = deepcopy(kwargs)
        next_kwargs['next_token'] = result.next_token
        result = invoke_with_throttling_retries(
            function_ref, *argv, **next_kwargs)
        final_result.extend(result)
    return final_result
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:31,代码来源:utils.py

示例2: __init__

 def __init__(self, connection=None, hosted_zone_id=None, comment=None):
     self.connection = connection
     self.hosted_zone_id = hosted_zone_id
     self.comment = comment
     self.changes = []
     self.next_record_name = None
     self.next_record_type = None
     ResultSet.__init__(self, [('ResourceRecordSet', Record)])
开发者ID:Didacti,项目名称:botornado,代码行数:8,代码来源:record.py

示例3: test_get_stacks_correctly_calls_aws_api

    def test_get_stacks_correctly_calls_aws_api(self, cloudformation_mock):
        stacks = [Mock(spec=Stack), Mock(spec=Stack)]

        result = ResultSet()
        result.extend(stacks)
        result.next_token = None
        cloudformation_mock.connect_to_region.return_value.describe_stacks.return_value = result

        cfn = CloudFormation()
        self.assertListEqual(stacks, cfn.get_stacks())
开发者ID:transacid,项目名称:cfn-sphere,代码行数:10,代码来源:cloudformation_api_tests.py

示例4: startElement

 def startElement(self, name, attrs, connection):
     if name == 'HealthCheck':
         self.health_check = HealthCheck(self)
         return self.health_check
     elif name == 'ListenerDescriptions':
         self.listeners = ResultSet([('member', Listener)])
         return self.listeners
     elif name == 'AvailabilityZones':
         return self.availability_zones
     elif name == 'Instances':
         self.instances = ResultSet([('member', InstanceInfo)])
         return self.instances
     elif name == 'Policies':
         self.policies = Policies(self)
         return self.policies
     elif name == 'SourceSecurityGroup':
         self.source_security_group = SecurityGroup()
         return self.source_security_group
     elif name == 'Subnets':
         return self.subnets
     elif name == 'SecurityGroups':
         return self.security_groups
     elif name == 'VPCId':
         pass
     elif name == "BackendServerDescriptions":
         self.backends = ResultSet([('member', Backend)])
         return self.backends
     else:
         return None
开发者ID:Grindizer,项目名称:boto,代码行数:29,代码来源:loadbalancer.py

示例5: restore

	def restore(self, data):
		obj = ResultSet.__new__(ResultSet)
		data.pop(jsonpickle.tags.OBJECT)
		items = data.pop(jsonpickle.tags.SEQ)
		items = self._base.restore(items)
		obj.extend(items)
		obj.__dict__.update(self._base.restore(data))
		return obj
开发者ID:jaraco,项目名称:recapturedocs,代码行数:8,代码来源:jsonpickle.py

示例6: endElement

 def endElement(self, name, value, connection):
     """Overwritten to also add the NextRecordName and
     NextRecordType to the base object"""
     if name == 'NextRecordName':
         self.next_record_name = value
     elif name == 'NextRecordType':
         self.next_record_type = value
     else:
         return ResultSet.endElement(self, name, value, connection)
开发者ID:Didacti,项目名称:botornado,代码行数:9,代码来源:record.py

示例7: get_all_groups

def get_all_groups(names=None, max_records=None, next_token=None):

    groups = ResultSet()

    for i in xrange(1, 3):
        tags = [
            boto.ec2.autoscale.tag.Tag(
                None,
                key='aws:cloudformation:stack-name',
                value='test{0}'.format(i))
        ]

        asg = AutoScalingGroup()
        asg.name = 'test{0}'.format(i)
        asg.tags = tags
        groups.append(asg)
        groups.next_token = None
    return groups
开发者ID:bennythejudge,项目名称:bootstrap-cfn,代码行数:18,代码来源:test_autoscale.py

示例8: __iter__

 def __iter__(self):
     """Override the next function to support paging"""
     results = ResultSet.__iter__(self)
     while results:
         for obj in results:
             yield obj
         if self.is_truncated:
             self.is_truncated = False
             results = self.connection.get_all_rrsets(self.hosted_zone_id, name=self.next_record_name, type=self.next_record_type)
         else:
             results = None
开发者ID:Didacti,项目名称:botornado,代码行数:11,代码来源:record.py

示例9: test_resultset_next_token

    def test_resultset_next_token(self):
        result = ResultSet()
        result.next_token = 'foo'
        func = Mock()
        final_result = Mock()

        with patch.multiple(
                pbm,
                invoke_with_throttling_retries=DEFAULT,
                _paginate_resultset=DEFAULT,
                _paginate_dict=DEFAULT,
        ) as mocks:
            mocks['invoke_with_throttling_retries'].return_value = result
            mocks['_paginate_resultset'].return_value = final_result
            res = paginate_query(func, 'foo', bar='barval')
        assert res == final_result
        assert mocks['invoke_with_throttling_retries'].mock_calls == [
            call(func, 'foo', bar='barval')
        ]
        assert mocks['_paginate_resultset'].mock_calls == [
            call(result, func, 'foo', bar='barval')
        ]
        assert mocks['_paginate_dict'].mock_calls == []
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:23,代码来源:test_utils.py

示例10: test_get_stacks_correctly_aggregates_paged_results

    def test_get_stacks_correctly_aggregates_paged_results(self, cloudformation_mock):
        stacks_1 = [Mock(spec=Stack), Mock(spec=Stack)]
        stacks_2 = [Mock(spec=Stack), Mock(spec=Stack)]

        result_1 = ResultSet()
        result_1.extend(stacks_1)
        result_1.next_token = "my-next-token"

        result_2 = ResultSet()
        result_2.extend(stacks_2)
        result_2.next_token = None

        cloudformation_mock.connect_to_region.return_value.describe_stacks.side_effect = [result_1, result_2]

        cfn = CloudFormation()
        self.assertListEqual(stacks_1 + stacks_2, cfn.get_stacks())
开发者ID:transacid,项目名称:cfn-sphere,代码行数:16,代码来源:cloudformation_api_tests.py

示例11: startElement

 def startElement(self, name, attrs, connection):
     if name == 'HealthCheck':
         self.health_check = HealthCheck(self)
         return self.health_check
     elif name == 'ListenerDescriptions':
         self.listeners = ResultSet([('member', Listener)])
         return self.listeners
     elif name == 'AvailabilityZones':
         return self.availability_zones
     elif name == 'Instances':
         self.instances = ResultSet([('member', InstanceInfo)])
         return self.instances
     else:
         return None
开发者ID:bgreenlee,项目名称:boto,代码行数:14,代码来源:loadbalancer.py

示例12: test_update_limits_from_api

    def test_update_limits_from_api(self):
        mock_conn = Mock(spec_set=EC2Connection)

        rs = ResultSet()
        a1 = AccountAttribute(connection=mock_conn)
        a1.attribute_name = 'supported-platforms'
        a1.attribute_values = ['EC2', 'VPC']
        rs.append(a1)
        a2 = AccountAttribute(connection=mock_conn)
        a2.attribute_name = 'vpc-max-security-groups-per-interface'
        a2.attribute_values = ['5']
        rs.append(a2)
        a3 = AccountAttribute(connection=mock_conn)
        a3.attribute_name = 'max-elastic-ips'
        a3.attribute_values = ['40']
        rs.append(a3)
        a4 = AccountAttribute(connection=mock_conn)
        a4.attribute_name = 'max-instances'
        a4.attribute_values = ['400']
        rs.append(a4)
        a5 = AccountAttribute(connection=mock_conn)
        a5.attribute_name = 'vpc-max-elastic-ips'
        a5.attribute_values = ['200']
        rs.append(a5)
        a6 = AccountAttribute(connection=mock_conn)
        a6.attribute_name = 'default-vpc'
        a6.attribute_values = ['none']
        rs.append(a6)

        cls = _Ec2Service(21, 43)
        cls.conn = mock_conn
        with patch('awslimitchecker.services.ec2.logger') as mock_logger:
            with patch('%s.boto_query_wrapper' % self.pbm) as mock_wrapper:
                mock_wrapper.return_value = rs
                cls._update_limits_from_api()
        assert mock_wrapper.mock_calls == [
            call(mock_conn.describe_account_attributes)
        ]
        assert mock_conn.mock_calls == []
        assert mock_logger.mock_calls == [
            call.info("Querying EC2 DescribeAccountAttributes for limits"),
            call.debug('Done setting limits from API')
        ]
        assert cls.limits['Elastic IP addresses (EIPs)'].api_limit == 40
        assert cls.limits['Running On-Demand EC2 instances'].api_limit == 400
        assert cls.limits['VPC Elastic IP addresses (EIPs)'].api_limit == 200
        assert cls.limits['VPC security groups per elastic '
                          'network interface'].api_limit == 5
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:48,代码来源:test_ec2.py

示例13: LoadBalancer

class LoadBalancer(object):
    """
    Represents an EC2 Load Balancer.
    """

    def __init__(self, connection=None, name=None, endpoints=None):
        """
        :ivar boto.ec2.elb.ELBConnection connection: The connection this load
            balancer was instance was instantiated from.
        :ivar list listeners: A list of tuples in the form of
            ``(<Inbound port>, <Outbound port>, <Protocol>)``
        :ivar boto.ec2.elb.healthcheck.HealthCheck health_check: The health
            check policy for this load balancer.
        :ivar boto.ec2.elb.policies.Policies policies: Cookie stickiness and
            other policies.
        :ivar str dns_name: The external DNS name for the balancer.
        :ivar str created_time: A date+time string showing when the
            load balancer was created.
        :ivar list instances: A list of :py:class:`boto.ec2.instanceinfo.InstanceInfo`
            instances, representing the EC2 instances this load balancer is
            distributing requests to.
        :ivar list availability_zones: The availability zones this balancer
            covers.
        :ivar str canonical_hosted_zone_name: Current CNAME for the balancer.
        :ivar str canonical_hosted_zone_name_id: The Route 53 hosted zone
            ID of this balancer. Needed when creating an Alias record in a
            Route 53 hosted zone.
        :ivar boto.ec2.elb.securitygroup.SecurityGroup source_security_group:
            The security group that you can use as part of your inbound rules
            for your load balancer back-end instances to disallow traffic
            from sources other than your load balancer.
        :ivar list subnets: A list of subnets this balancer is on.
        :ivar list security_groups: A list of additional security groups that
            have been applied.
        :ivar str vpc_id: The ID of the VPC that this ELB resides within.
        :ivar list backends: A list of :py:class:`boto.ec2.elb.loadbalancer.Backend
            back-end server descriptions.
        """
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.policies = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()
        self.canonical_hosted_zone_name = None
        self.canonical_hosted_zone_name_id = None
        self.source_security_group = None
        self.subnets = ListElement()
        self.security_groups = ListElement()
        self.vpc_id = None
        self.scheme = None
        self.backends = None
        self._attributes = None

    def __repr__(self):
        return "LoadBalancer:%s" % self.name

    def startElement(self, name, attrs, connection):
        if name == "HealthCheck":
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == "ListenerDescriptions":
            self.listeners = ResultSet([("member", Listener)])
            return self.listeners
        elif name == "AvailabilityZones":
            return self.availability_zones
        elif name == "Instances":
            self.instances = ResultSet([("member", InstanceInfo)])
            return self.instances
        elif name == "Policies":
            self.policies = Policies(self)
            return self.policies
        elif name == "SourceSecurityGroup":
            self.source_security_group = SecurityGroup()
            return self.source_security_group
        elif name == "Subnets":
            return self.subnets
        elif name == "SecurityGroups":
            return self.security_groups
        elif name == "VPCId":
            pass
        elif name == "BackendServerDescriptions":
            self.backends = ResultSet([("member", Backend)])
            return self.backends
        else:
            return None

    def endElement(self, name, value, connection):
        if name == "LoadBalancerName":
            self.name = value
        elif name == "DNSName":
            self.dns_name = value
        elif name == "CreatedTime":
            self.created_time = value
        elif name == "InstanceId":
            self.instances.append(value)
        elif name == "CanonicalHostedZoneName":
#.........这里部分代码省略.........
开发者ID:rmamba,项目名称:boto,代码行数:101,代码来源:loadbalancer.py

示例14: LoadBalancer

class LoadBalancer(object):
    """
    Represents an EC2 Load Balancer, extended to support Euca-specific Loadbalancer definition
    """

    def __init__(self, connection=None, name=None, endpoints=None):
        """
        :ivar boto.ec2.elb.ELBConnection connection: The connection this load
            balancer was instance was instantiated from.
        :ivar list listeners: A list of tuples in the form of
            ``(<Inbound port>, <Outbound port>, <Protocol>)``
        :ivar boto.ec2.elb.healthcheck.HealthCheck health_check: The health
            check policy for this load balancer.
        :ivar list servo.ws.policies.PolicyDescription: A list of load balancer policies
        :ivar str name: The name of the Load Balancer.
        :ivar str dns_name: The external DNS name for the balancer.
        :ivar str created_time: A date+time string showing when the
            load balancer was created.
        :ivar list instances: A list of :py:class:`servo.ws.backend_instance.BackendInstance`
            instances, representing the EC2 instances this load balancer is
            distributing requests to.
        :ivar list availability_zones: The availability zones this balancer
            covers.
        :ivar str canonical_hosted_zone_name: Current CNAME for the balancer.
        :ivar str canonical_hosted_zone_name_id: The Route 53 hosted zone
            ID of this balancer. Needed when creating an Alias record in a
            Route 53 hosted zone.
        :ivar boto.ec2.elb.securitygroup.SecurityGroup source_security_group:
            The security group that you can use as part of your inbound rules
            for your load balancer back-end instances to disallow traffic
            from sources other than your load balancer.
        :ivar list subnets: A list of subnets this balancer is on.
        :ivar list security_groups: A list of additional security groups that
            have been applied.
        :ivar str vpc_id: The ID of the VPC that this ELB resides within.
        :ivar list backends: A list of :py:class:`boto.ec2.elb.loadbalancer.Backend
            back-end server descriptions.
        """
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.policy_descriptions = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()
        self.canonical_hosted_zone_name = None
        self.canonical_hosted_zone_name_id = None
        self.source_security_group = None
        self.subnets = ListElement()
        self.security_groups = ListElement()
        self.vpc_id = None
        self.scheme = None
        self.backends = None
        self.attributes = None

    def __repr__(self):
        return 'LoadBalancer:%s' % self.name

    def startElement(self, name, attrs, connection):
        if name == 'HealthCheck':
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == 'ListenerDescriptions':
            self.listeners = ResultSet([('member', Listener)])
            return self.listeners
        elif name == 'AvailabilityZones':
            return self.availability_zones
        elif name == 'BackendInstances':
            self.instances = ResultSet([('member', BackendInstance)])
            return self.instances
        elif name == 'PolicyDescriptions':
            self.policy_descriptions = ResultSet([('member', PolicyDescription)])
            return self.policy_descriptions
        elif name == 'SourceSecurityGroup':
            self.source_security_group = SecurityGroup()
            return self.source_security_group
        elif name == 'Subnets':
            return self.subnets
        elif name == 'SecurityGroups':
            return self.security_groups
        elif name == 'VPCId':
            pass
        elif name == "BackendServerDescriptions":
            self.backends = ResultSet([('member', Backend)])
            return self.backends
        elif name == "LoadBalancerAttributes":
            self.attributes = LbAttributes(self)
            return self.attributes
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'LoadBalancerName':
            self.name = value
        elif name == 'DNSName':
            self.dns_name = value
        elif name == 'CreatedTime':
            self.created_time = value
#.........这里部分代码省略.........
开发者ID:eucalyptus,项目名称:load-balancer-servo,代码行数:101,代码来源:loadbalancer.py

示例15: test_resultset_two_next

    def test_resultset_two_next(self):
        e1 = Mock()
        e2 = Mock()
        rs1 = ResultSet()
        rs1.append(e1)
        rs1.append(e2)
        rs1.next_token = 't1'

        e3 = Mock()
        e4 = Mock()
        rs2 = ResultSet()
        rs2.append(e3)
        rs2.append(e4)
        rs2.next_token = 't2'

        e5 = Mock()
        e6 = Mock()
        rs3 = ResultSet()
        rs3.append(e5)
        rs3.append(e6)

        func = Mock()

        results = [rs2, rs3]

        def se_invoke(f, *args, **argv):
            return results.pop(0)

        with patch('%s.invoke_with_throttling_retries' % pbm) as mock_invoke:
            mock_invoke.side_effect = se_invoke
            res = _paginate_resultset(rs1, func, 'foo', bar='barval')
        assert isinstance(res, ResultSet)
        assert len(res) == 6
        assert res[0] == e1
        assert res[1] == e2
        assert res[2] == e3
        assert res[3] == e4
        assert res[4] == e5
        assert res[5] == e6
        assert mock_invoke.mock_calls == [
            call(func, 'foo', bar='barval', next_token='t1'),
            call(func, 'foo', bar='barval', next_token='t2')
        ]
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:43,代码来源:test_utils.py


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