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

Python utils.iso_8601_datetime_with_milliseconds函数代码示例

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

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



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

示例1: test_request_spot_instances

def test_request_spot_instances():
    conn = boto3.client('ec2', 'us-east-1')
    vpc = conn.create_vpc(CidrBlock="10.0.0.0/8")['Vpc']
    subnet = conn.create_subnet(VpcId=vpc['VpcId'], CidrBlock='10.0.0.0/16', AvailabilityZone='us-east-1a')['Subnet']
    subnet_id = subnet['SubnetId']

    conn = boto.connect_ec2()

    conn.create_security_group('group1', 'description')
    conn.create_security_group('group2', 'description')

    start = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 1))
    end = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 2))

    with assert_raises(JSONResponseError) as ex:
        request = conn.request_spot_instances(
            price=0.5, image_id='ami-abcd1234', count=1, type='one-time',
            valid_from=start, valid_until=end, launch_group="the-group",
            availability_zone_group='my-group', key_name="test",
            security_groups=['group1', 'group2'], user_data=b"some test data",
            instance_type='m1.small', placement='us-east-1c',
            kernel_id="test-kernel", ramdisk_id="test-ramdisk",
            monitoring_enabled=True, subnet_id=subnet_id, dry_run=True
        )
    ex.exception.reason.should.equal('DryRunOperation')
    ex.exception.status.should.equal(400)
    ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the RequestSpotInstance operation: Request would have succeeded, but DryRun flag is set')

    request = conn.request_spot_instances(
        price=0.5, image_id='ami-abcd1234', count=1, type='one-time',
        valid_from=start, valid_until=end, launch_group="the-group",
        availability_zone_group='my-group', key_name="test",
        security_groups=['group1', 'group2'], user_data=b"some test data",
        instance_type='m1.small', placement='us-east-1c',
        kernel_id="test-kernel", ramdisk_id="test-ramdisk",
        monitoring_enabled=True, subnet_id=subnet_id,
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")
    request.price.should.equal(0.5)
    request.launch_specification.image_id.should.equal('ami-abcd1234')
    request.type.should.equal('one-time')
    request.valid_from.should.equal(start)
    request.valid_until.should.equal(end)
    request.launch_group.should.equal("the-group")
    request.availability_zone_group.should.equal('my-group')
    request.launch_specification.key_name.should.equal("test")
    security_group_names = [group.name for group in request.launch_specification.groups]
    set(security_group_names).should.equal(set(['group1', 'group2']))
    request.launch_specification.instance_type.should.equal('m1.small')
    request.launch_specification.placement.should.equal('us-east-1c')
    request.launch_specification.kernel.should.equal("test-kernel")
    request.launch_specification.ramdisk.should.equal("test-ramdisk")
    request.launch_specification.subnet_id.should.equal(subnet_id)
开发者ID:balintzs,项目名称:moto,代码行数:58,代码来源:test_spot_instances.py


示例2: to_dict

 def to_dict(self):
     return {
         "id": self.id,
         "name": self.name,
         "description": self.description,
         "createdDate": iso_8601_datetime_with_milliseconds(self.create_date),
     }
开发者ID:carldunham,项目名称:moto,代码行数:7,代码来源:models.py


示例3: __init__

 def __init__(self, deployment_id, name, description=""):
     super(Deployment, self).__init__()
     self['id'] = deployment_id
     self['stageName'] = name
     self['description'] = description
     self['createdDate'] = iso_8601_datetime_with_milliseconds(
         datetime.datetime.now())
开发者ID:2rs2ts,项目名称:moto,代码行数:7,代码来源:models.py


示例4: __init__

 def __init__(self, cluster, snapshot_identifier, region_name, tags=None):
     super(Snapshot, self).__init__(region_name, tags)
     self.cluster = copy.copy(cluster)
     self.snapshot_identifier = snapshot_identifier
     self.snapshot_type = 'manual'
     self.status = 'available'
     self.create_time = iso_8601_datetime_with_milliseconds(
         datetime.datetime.now())
开发者ID:Affirm,项目名称:moto,代码行数:8,代码来源:models.py


示例5: __init__

    def __init__(self, redshift_backend, cluster_identifier, node_type, master_username,
                 master_user_password, db_name, cluster_type, cluster_security_groups,
                 vpc_security_group_ids, cluster_subnet_group_name, availability_zone,
                 preferred_maintenance_window, cluster_parameter_group_name,
                 automated_snapshot_retention_period, port, cluster_version,
                 allow_version_upgrade, number_of_nodes, publicly_accessible,
                 encrypted, region_name, tags=None, iam_roles_arn=None,
                 restored_from_snapshot=False):
        super(Cluster, self).__init__(region_name, tags)
        self.redshift_backend = redshift_backend
        self.cluster_identifier = cluster_identifier
        self.create_time = iso_8601_datetime_with_milliseconds(datetime.datetime.now())
        self.status = 'available'
        self.node_type = node_type
        self.master_username = master_username
        self.master_user_password = master_user_password
        self.db_name = db_name if db_name else "dev"
        self.vpc_security_group_ids = vpc_security_group_ids
        self.cluster_subnet_group_name = cluster_subnet_group_name
        self.publicly_accessible = publicly_accessible
        self.encrypted = encrypted

        self.allow_version_upgrade = allow_version_upgrade if allow_version_upgrade is not None else True
        self.cluster_version = cluster_version if cluster_version else "1.0"
        self.port = int(port) if port else 5439
        self.automated_snapshot_retention_period = int(
            automated_snapshot_retention_period) if automated_snapshot_retention_period else 1
        self.preferred_maintenance_window = preferred_maintenance_window if preferred_maintenance_window else "Mon:03:00-Mon:03:30"

        if cluster_parameter_group_name:
            self.cluster_parameter_group_name = [cluster_parameter_group_name]
        else:
            self.cluster_parameter_group_name = ['default.redshift-1.0']

        if cluster_security_groups:
            self.cluster_security_groups = cluster_security_groups
        else:
            self.cluster_security_groups = ["Default"]

        if availability_zone:
            self.availability_zone = availability_zone
        else:
            # This could probably be smarter, but there doesn't appear to be a
            # way to pull AZs for a region in boto
            self.availability_zone = region_name + "a"

        if cluster_type == 'single-node':
            self.number_of_nodes = 1
        elif number_of_nodes:
            self.number_of_nodes = int(number_of_nodes)
        else:
            self.number_of_nodes = 1

        self.iam_roles_arn = iam_roles_arn or []
        self.restored_from_snapshot = restored_from_snapshot
开发者ID:spulec,项目名称:moto,代码行数:55,代码来源:models.py


示例6: get_post_data

 def get_post_data(self, message, message_id, subject):
     return {
         "Type": "Notification",
         "MessageId": message_id,
         "TopicArn": self.topic.arn,
         "Subject": subject or "my subject",
         "Message": message,
         "Timestamp": iso_8601_datetime_with_milliseconds(datetime.datetime.utcnow()),
         "SignatureVersion": "1",
         "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
         "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
         "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
     }
开发者ID:Affirm,项目名称:moto,代码行数:13,代码来源:models.py


示例7: test_request_spot_instances

def test_request_spot_instances():
    conn = boto.connect_ec2()

    conn.create_security_group('group1', 'description')
    conn.create_security_group('group2', 'description')

    start = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 1))
    end = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 2))

    request = conn.request_spot_instances(
        price=0.5, image_id='ami-abcd1234', count=1, type='one-time',
        valid_from=start, valid_until=end, launch_group="the-group",
        availability_zone_group='my-group', key_name="test",
        security_groups=['group1', 'group2'], user_data=b"some test data",
        instance_type='m1.small', placement='us-east-1c',
        kernel_id="test-kernel", ramdisk_id="test-ramdisk",
        monitoring_enabled=True, subnet_id="subnet123",
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")
    request.price.should.equal(0.5)
    request.launch_specification.image_id.should.equal('ami-abcd1234')
    request.type.should.equal('one-time')
    request.valid_from.should.equal(start)
    request.valid_until.should.equal(end)
    request.launch_group.should.equal("the-group")
    request.availability_zone_group.should.equal('my-group')
    request.launch_specification.key_name.should.equal("test")
    security_group_names = [group.name for group in request.launch_specification.groups]
    set(security_group_names).should.equal(set(['group1', 'group2']))
    request.launch_specification.instance_type.should.equal('m1.small')
    request.launch_specification.placement.should.equal('us-east-1c')
    request.launch_specification.kernel.should.equal("test-kernel")
    request.launch_specification.ramdisk.should.equal("test-ramdisk")
    request.launch_specification.subnet_id.should.equal("subnet123")
开发者ID:DarthLorenzo,项目名称:moto,代码行数:39,代码来源:test_spot_instances.py


示例8: get_credentials_for_identity

 def get_credentials_for_identity(self, identity_id):
     duration = 90
     now = datetime.datetime.utcnow()
     expiration = now + datetime.timedelta(seconds=duration)
     expiration_str = str(iso_8601_datetime_with_milliseconds(expiration))
     response = json.dumps(
         {
             "Credentials":
             {
                 "AccessKeyId": "TESTACCESSKEY12345",
                 "Expiration": expiration_str,
                 "SecretKey": "ABCSECRETKEY",
                 "SessionToken": "ABC12345"
             },
             "IdentityId": identity_id
         })
     return response
开发者ID:botify-labs,项目名称:moto,代码行数:17,代码来源:models.py


示例9: test_request_spot_instances

def test_request_spot_instances():
    conn = boto3.client('ec2', 'us-east-1')
    vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")['Vpc']
    subnet = conn.create_subnet(
        VpcId=vpc['VpcId'], CidrBlock='10.0.0.0/16', AvailabilityZone='us-east-1a')['Subnet']
    subnet_id = subnet['SubnetId']

    conn.create_security_group(GroupName='group1', Description='description')
    conn.create_security_group(GroupName='group2', Description='description')

    start_dt = datetime.datetime(2013, 1, 1).replace(tzinfo=pytz.utc)
    end_dt = datetime.datetime(2013, 1, 2).replace(tzinfo=pytz.utc)
    start = iso_8601_datetime_with_milliseconds(start_dt)
    end = iso_8601_datetime_with_milliseconds(end_dt)

    with assert_raises(ClientError) as ex:
        request = conn.request_spot_instances(
            SpotPrice="0.5", InstanceCount=1, Type='one-time',
            ValidFrom=start, ValidUntil=end, LaunchGroup="the-group",
            AvailabilityZoneGroup='my-group',
            LaunchSpecification={
                "ImageId": 'ami-abcd1234',
                "KeyName": "test",
                "SecurityGroups": ['group1', 'group2'],
                "UserData": "some test data",
                "InstanceType": 'm1.small',
                "Placement": {
                    "AvailabilityZone": 'us-east-1c',
                },
                "KernelId": "test-kernel",
                "RamdiskId": "test-ramdisk",
                "Monitoring": {
                    "Enabled": True,
                },
                "SubnetId": subnet_id,
            },
            DryRun=True,
        )
    ex.exception.response['Error']['Code'].should.equal('DryRunOperation')
    ex.exception.response['ResponseMetadata'][
        'HTTPStatusCode'].should.equal(400)
    ex.exception.response['Error']['Message'].should.equal(
        'An error occurred (DryRunOperation) when calling the RequestSpotInstance operation: Request would have succeeded, but DryRun flag is set')

    request = conn.request_spot_instances(
        SpotPrice="0.5", InstanceCount=1, Type='one-time',
        ValidFrom=start, ValidUntil=end, LaunchGroup="the-group",
        AvailabilityZoneGroup='my-group',
        LaunchSpecification={
            "ImageId": 'ami-abcd1234',
            "KeyName": "test",
            "SecurityGroups": ['group1', 'group2'],
            "UserData": "some test data",
            "InstanceType": 'm1.small',
            "Placement": {
                "AvailabilityZone": 'us-east-1c',
            },
            "KernelId": "test-kernel",
            "RamdiskId": "test-ramdisk",
            "Monitoring": {
                "Enabled": True,
            },
            "SubnetId": subnet_id,
        },
    )

    requests = conn.describe_spot_instance_requests()['SpotInstanceRequests']
    requests.should.have.length_of(1)
    request = requests[0]

    request['State'].should.equal("open")
    request['SpotPrice'].should.equal("0.5")
    request['Type'].should.equal('one-time')
    request['ValidFrom'].should.equal(start_dt)
    request['ValidUntil'].should.equal(end_dt)
    request['LaunchGroup'].should.equal("the-group")
    request['AvailabilityZoneGroup'].should.equal('my-group')

    launch_spec = request['LaunchSpecification']
    security_group_names = [group['GroupName']
                            for group in launch_spec['SecurityGroups']]
    set(security_group_names).should.equal(set(['group1', 'group2']))

    launch_spec['ImageId'].should.equal('ami-abcd1234')
    launch_spec['KeyName'].should.equal("test")
    launch_spec['InstanceType'].should.equal('m1.small')
    launch_spec['KernelId'].should.equal("test-kernel")
    launch_spec['RamdiskId'].should.equal("test-ramdisk")
    launch_spec['SubnetId'].should.equal(subnet_id)
开发者ID:spulec,项目名称:moto,代码行数:89,代码来源:test_spot_instances.py


示例10: last_modified_ISO8601

 def last_modified_ISO8601(self):
     return iso_8601_datetime_with_milliseconds(self.last_modified)
开发者ID:cameron-r,项目名称:moto,代码行数:2,代码来源:models.py


示例11: expiration_ISO8601

 def expiration_ISO8601(self):
     return iso_8601_datetime_with_milliseconds(self.expiration)
开发者ID:2rs2ts,项目名称:moto,代码行数:2,代码来源:models.py


示例12: __init__

 def __init__(self, stats, dt):
     self.timestamp = iso_8601_datetime_with_milliseconds(dt)
     self.values = []
     self.stats = stats
开发者ID:botify-labs,项目名称:moto,代码行数:4,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.unix_time函数代码示例发布时间:2022-05-27
下一篇:
Python utils.camelcase_to_underscores函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap