本文整理汇总了Python中stacktach.datetime_to_decimal.dt_to_decimal函数的典型用法代码示例。如果您正苦于以下问题:Python dt_to_decimal函数的具体用法?Python dt_to_decimal怎么用?Python dt_to_decimal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_to_decimal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: find
def find(instance, launched):
start = launched - datetime.timedelta(microseconds=launched.microsecond)
end = start + datetime.timedelta(microseconds=999999)
params = {'instance': instance,
'launched_at__gte': dt.dt_to_decimal(start),
'launched_at__lte': dt.dt_to_decimal(end)}
return InstanceReconcile.objects.filter(**params)
开发者ID:ibravo,项目名称:stacktach,代码行数:7,代码来源:models.py
示例2: audit_for_period
def audit_for_period(beginning, ending, ums=False, ums_offset=0):
beginning_decimal = dt.dt_to_decimal(beginning)
ending_decimal = dt.dt_to_decimal(ending)
if ums:
verifier_audit_func = functools.partial(
usage_audit._verifier_audit_for_day_ums, ums_offset=ums_offset
)
else:
verifier_audit_func = usage_audit._verifier_audit_for_day
(verify_summary,
verify_detail) = verifier_audit_func(beginning_decimal, ending_decimal,
models.InstanceExists)
detail, new_count, old_count = _launch_audit_for_period(beginning_decimal,
ending_decimal)
summary = {
'verifier': verify_summary,
'launch_summary': {
'new_launches': new_count,
'old_launches': old_count,
'failures': len(detail)
},
}
details = {
'exist_fails': verify_detail,
'launch_fails': detail,
}
return summary, details
开发者ID:Lupul,项目名称:stacktach,代码行数:32,代码来源:nova_usage_audit.py
示例3: audit_for_period
def audit_for_period(beginning, ending):
beginning_decimal = dt.dt_to_decimal(beginning)
ending_decimal = dt.dt_to_decimal(ending)
image_event_counts = __get_image_activate_count(beginning_decimal, ending_decimal)
return image_event_counts
开发者ID:meker12,项目名称:stacktach,代码行数:7,代码来源:image_events_audit.py
示例4: audit_for_period
def audit_for_period(beginning, ending):
beginning_decimal = dt.dt_to_decimal(beginning)
ending_decimal = dt.dt_to_decimal(ending)
(verify_summary,
verify_detail) = _verifier_audit_for_day(beginning_decimal,
ending_decimal)
detail, new_count, old_count = _launch_audit_for_period(beginning_decimal,
ending_decimal)
summary = {
'verifier': verify_summary,
'launch_summary': {
'new_launches': new_count,
'old_launches': old_count,
'failures': len(detail)
},
}
details = {
'exist_fails': verify_detail,
'launch_fails': detail,
}
return summary, details
开发者ID:thomasem,项目名称:stacktach,代码行数:25,代码来源:nova_usage_audit.py
示例5: __audit_for_instance_exists
def __audit_for_instance_exists(beginning, ending):
beginning_decimal = dt.dt_to_decimal(beginning)
ending_decimal = dt.dt_to_decimal(ending)
instance_exists = __get_instance_exists(beginning_decimal, ending_decimal)
total_bw = reduce(lambda x, y: x + y.bandwidth_public_out, instance_exists, 0)
report = {"total_public_outbound_bandwidth": total_bw}
return report
开发者ID:meker12,项目名称:stacktach,代码行数:8,代码来源:public_outbound_bandwidth.py
示例6: _delete_for_instance
def _delete_for_instance(instance):
delete = {
'instance': instance['uuid'],
'deleted_at': dt.dt_to_decimal(instance.get('deleted_at')),
}
launched_at = instance.get('launched_at')
if launched_at is not None:
delete['launched_at'] = dt.dt_to_decimal(launched_at)
return delete
开发者ID:Lupul,项目名称:stacktach,代码行数:10,代码来源:usage_seed.py
示例7: _list_exists
def _list_exists(received_max=None, received_min=None, status=None):
params = {}
if received_max:
params['raw__when__lte'] = dt.dt_to_decimal(received_max)
if received_min:
params['raw__when__gt'] = dt.dt_to_decimal(received_min)
if status:
params['status'] = status
return models.InstanceExists.objects.select_related()\
.filter(**params).order_by('id')
开发者ID:AsherBond,项目名称:stacktach,代码行数:10,代码来源:dbverifier.py
示例8: audit_for_period
def audit_for_period(beginning, ending):
beginning_decimal = dt.dt_to_decimal(beginning)
ending_decimal = dt.dt_to_decimal(ending)
(verify_summary, verify_detail) = _verifier_audit_for_day(beginning_decimal, ending_decimal)
detail, new_count, old_count = _launch_audit_for_period(beginning_decimal, ending_decimal)
summary = {
"verifier": verify_summary,
"launch_summary": {"new_launches": new_count, "old_launches": old_count, "failures": len(detail)},
}
details = {"exist_fails": verify_detail, "launch_fails": detail}
return summary, details
开发者ID:kiall,项目名称:stacktach,代码行数:15,代码来源:nova_usage_audit.py
示例9: process_raw_data
def process_raw_data(deployment, args, json_args):
"""This is called directly by the worker to add the event to the db."""
db.reset_queries()
routing_key, body = args
record = None
handler = HANDLERS.get(routing_key, None)
if handler:
values = handler(routing_key, body)
if not values:
return record
values['deployment'] = deployment
try:
when = body['timestamp']
except KeyError:
when = body['_context_timestamp'] # Old way of doing it
try:
try:
when = datetime.datetime.strptime(when, "%Y-%m-%d %H:%M:%S.%f")
except ValueError:
# Old way of doing it
when = datetime.datetime.strptime(when, "%Y-%m-%dT%H:%M:%S.%f")
except Exception, e:
pass
values['when'] = dt.dt_to_decimal(when)
values['routing_key'] = routing_key
values['json'] = json_args
record = STACKDB.create_rawdata(**values)
STACKDB.save(record)
aggregate_lifecycle(record)
aggregate_usage(record)
开发者ID:swat30,项目名称:stacktach,代码行数:33,代码来源:views.py
示例10: test_create_raw_data_should_populate_rawdata_and_rawdata_imagemeta
def test_create_raw_data_should_populate_rawdata_and_rawdata_imagemeta(self):
deployment = db.get_or_create_deployment('deployment1')[0]
kwargs = {
'deployment': deployment,
'when': dt_to_decimal(datetime.utcnow()),
'tenant': '1', 'json': '{}', 'routing_key': 'monitor.info',
'state': 'verifying', 'old_state': 'pending',
'old_task': '', 'task': '', 'image_type': 1,
'publisher': '', 'event': 'compute.instance.exists',
'service': '', 'host': '', 'instance': '1234-5678-9012-3456',
'request_id': '1234', 'os_architecture': 'x86', 'os_version': '1',
'os_distro': 'windows', 'rax_options': '2'}
rawdata = db.create_rawdata(**kwargs)
for field in get_model_fields(RawData):
if field.name != 'id':
self.assertEquals(getattr(rawdata, field.name),
kwargs[field.name])
raw_image_meta = RawDataImageMeta.objects.all()[0]
self.assertEquals(raw_image_meta.raw, rawdata)
self.assertEquals(raw_image_meta.os_architecture,
kwargs['os_architecture'])
self.assertEquals(raw_image_meta.os_version, kwargs['os_version'])
self.assertEquals(raw_image_meta.os_distro, kwargs['os_distro'])
self.assertEquals(raw_image_meta.rax_options, kwargs['rax_options'])
开发者ID:huangshunping,项目名称:stacktach,代码行数:27,代码来源:tests.py
示例11: test_verify_for_range_with_callback
def test_verify_for_range_with_callback(self):
callback = self.mox.CreateMockAnything()
pool = self.mox.CreateMockAnything()
when_max = datetime.datetime.utcnow()
results = self.mox.CreateMockAnything()
models.InstanceExists.objects.select_related().AndReturn(results)
models.InstanceExists.PENDING = 'pending'
models.InstanceExists.VERIFYING = 'verifying'
filters = {
'audit_period_ending__lte': dt.dt_to_decimal(when_max),
'status': 'pending'
}
results.filter(**filters).AndReturn(results)
results.order_by('id').AndReturn(results)
results.count().AndReturn(2)
exist1 = self.mox.CreateMockAnything()
exist2 = self.mox.CreateMockAnything()
results.__getslice__(0, 1000).AndReturn(results)
results.__iter__().AndReturn([exist1, exist2].__iter__())
exist1.save()
exist2.save()
self.pool.apply_async(dbverifier._verify, args=(exist1,),
callback=callback)
self.pool.apply_async(dbverifier._verify, args=(exist2,),
callback=callback)
self.mox.ReplayAll()
self.verifier.verify_for_range(when_max, callback=callback)
self.assertEqual(exist1.status, 'verifying')
self.assertEqual(exist2.status, 'verifying')
self.mox.VerifyAll()
开发者ID:kiall,项目名称:stacktach,代码行数:30,代码来源:test_verifier_db.py
示例12: test_group_exists_with_date_status_in_audit_period_by_owner_rawid
def test_group_exists_with_date_status_in_audit_period_by_owner_rawid(self):
end_max = datetime.utcnow()
status = 'pending'
exist1 = self.mox.CreateMockAnything()
exist1.owner = "owner1"
exist1.raw_id = "1"
exist2 = self.mox.CreateMockAnything()
exist2.owner = "owner2"
exist2.raw_id = "2"
exist3 = self.mox.CreateMockAnything()
exist3.owner = "owner1"
exist3.raw_id = "1"
exist4 = self.mox.CreateMockAnything()
exist4.owner = "owner1"
exist4.raw_id = "3"
ordered_results = [exist1, exist3, exist4, exist2]
unordered_results = self.mox.CreateMockAnything()
related_results = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(ImageExists.objects, 'select_related')
ImageExists.objects.select_related().AndReturn(related_results)
related_results.filter(
audit_period_ending__lte=dt.dt_to_decimal(end_max),
status=status).AndReturn(unordered_results)
unordered_results.order_by('owner').AndReturn(ordered_results)
self.mox.ReplayAll()
results = ImageExists.find_and_group_by_owner_and_raw_id(end_max,
status)
self.mox.VerifyAll()
self.assertEqual(results, {'owner1-1': [exist1, exist3],
'owner1-3': [exist4],
'owner2-2': [exist2]})
开发者ID:dinobot,项目名称:stacktach,代码行数:34,代码来源:test_models.py
示例13: _list_exists
def _list_exists(ending_max=None, status=None):
params = {}
if ending_max:
params['audit_period_ending__lte'] = dt.dt_to_decimal(ending_max)
if status:
params['status'] = status
return models.InstanceExists.objects.select_related()\
.filter(**params).order_by('id')
开发者ID:pperezrubio,项目名称:stacktach,代码行数:8,代码来源:dbverifier.py
示例14: str_time_to_unix
def str_time_to_unix(when):
if 'Z' in when:
when = _try_parse(when, ["%Y-%m-%dT%H:%M:%SZ", "%Y-%m-%dT%H:%M:%S.%fZ"])
elif 'T' in when:
when = _try_parse(when, ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%dT%H:%M:%S"])
else:
when = _try_parse(when, ["%Y-%m-%d %H:%M:%S.%f", "%Y-%m-%d %H:%M:%S"])
return dt.dt_to_decimal(when)
开发者ID:Lupul,项目名称:stacktach,代码行数:9,代码来源:utils.py
示例15: _usage_for_image
def _usage_for_image(image):
return {
'uuid': image.id,
'owner': image.owner,
'created_at': dt.dt_to_decimal(image.created_at),
'owner': image.owner,
'size': image.size,
'last_raw_id': None
}
开发者ID:Lupul,项目名称:stacktach,代码行数:9,代码来源:glance_usage_seed.py
示例16: __store_report_in_db
def __store_report_in_db(start, end, report):
values = {
'json': __make_json_report(report),
'created': dt.dt_to_decimal(datetime.datetime.utcnow()),
'period_start': start,
'period_end': end,
'version': 1,
'name': 'public outbound bandwidth'
}
report = models.JsonReport(**values)
report.save()
开发者ID:anujm,项目名称:stacktach,代码行数:12,代码来源:public_outbound_bandwidth.py
示例17: __store_report_in_db
def __store_report_in_db(start, end, report):
values = {
"json": __make_json_report(report),
"created": dt.dt_to_decimal(datetime.datetime.utcnow()),
"period_start": start,
"period_end": end,
"version": 1,
"name": "public outbound bandwidth",
}
report = models.JsonReport(**values)
report.save()
开发者ID:meker12,项目名称:stacktach,代码行数:12,代码来源:public_outbound_bandwidth.py
示例18: __store_results
def __store_results(start, end, report):
values = {
"json": __make_json_report(report),
"created": dt.dt_to_decimal(datetime.datetime.utcnow()),
"period_start": start,
"period_end": end,
"version": 1,
"name": "image events audit",
}
report = models.JsonReport(**values)
report.save()
开发者ID:meker12,项目名称:stacktach,代码行数:12,代码来源:image_events_audit.py
示例19: store_results
def store_results(start, end, summary, details):
values = {
"json": make_json_report(summary, details),
"created": dt.dt_to_decimal(datetime.datetime.utcnow()),
"period_start": start,
"period_end": end,
"version": 3,
"name": "nova usage audit",
}
report = models.JsonReport(**values)
report.save()
开发者ID:kiall,项目名称:stacktach,代码行数:12,代码来源:nova_usage_audit.py
示例20: test_find_delete_should_return_delete_issued_before_given_time
def test_find_delete_should_return_delete_issued_before_given_time(self):
delete = self.mox.CreateMockAnything()
deleted_max = datetime.utcnow()
self.mox.StubOutWithMock(ImageDeletes.objects, 'filter')
ImageDeletes.objects.filter(
uuid=IMAGE_UUID_1,
deleted_at__lte=dt.dt_to_decimal(deleted_max)).AndReturn(delete)
self.mox.ReplayAll()
self.assertEquals(ImageDeletes.find(
IMAGE_UUID_1, deleted_max), delete)
self.mox.VerifyAll()
开发者ID:dinobot,项目名称:stacktach,代码行数:12,代码来源:test_models.py
注:本文中的stacktach.datetime_to_decimal.dt_to_decimal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论