本文整理汇总了Python中pulp.common.dateutils.now_utc_datetime_with_tzinfo函数的典型用法代码示例。如果您正苦于以下问题:Python now_utc_datetime_with_tzinfo函数的具体用法?Python now_utc_datetime_with_tzinfo怎么用?Python now_utc_datetime_with_tzinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了now_utc_datetime_with_tzinfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_transfer_repo
def test_to_transfer_repo(self):
"""
Test changing a repository object into a transfer unit for plugins.
"""
dt = dateutils.now_utc_datetime_with_tzinfo()
data = {
'repo_id': 'foo',
'display_name': 'bar',
'description': 'baz',
'notes': 'qux',
'content_unit_counts': {'units': 1},
'last_unit_added': dt,
'last_unit_removed': dt
}
repo_obj = model.Repository(**data)
repo = repo_obj.to_transfer_repo()
self.assertEquals('foo', repo.id)
self.assertFalse(hasattr(repo, 'repo_id'))
self.assertEquals('bar', repo.display_name)
self.assertEquals('baz', repo.description)
self.assertEquals('qux', repo.notes)
self.assertEquals({'units': 1}, repo.content_unit_counts)
self.assertEquals(dt, repo.last_unit_added)
self.assertEquals(dt, repo.last_unit_removed)
self.assertEquals(repo_obj, repo.repo_obj)
示例2: test_create_datetime
def test_create_datetime(self):
comparator = datetime.datetime.now(tz=dateutils.utc_tz())
result = dateutils.now_utc_datetime_with_tzinfo()
self.assertTrue(hasattr(result, 'tzinfo'))
self.assertEquals(result.tzinfo, dateutils.utc_tz())
self.assertTrue(result >= comparator)
示例3: assert_last_sync_time
def assert_last_sync_time(time_in_iso):
now = dateutils.now_utc_datetime_with_tzinfo()
finished = dateutils.parse_iso8601_datetime(time_in_iso)
# Compare them within a threshold since they won't be exact
difference = now - finished
return difference.seconds < 2
示例4: add_result
def add_result(repo_id, dist_id, offset):
started = dateutils.now_utc_datetime_with_tzinfo()
completed = started + datetime.timedelta(days=offset)
r = RepoPublishResult.expected_result(
repo_id, dist_id, 'bar', dateutils.format_iso8601_datetime(started),
dateutils.format_iso8601_datetime(completed), 'test-summary', 'test-details',
RepoPublishResult.RESULT_SUCCESS)
RepoPublishResult.get_collection().insert(r, safe=True)
示例5: _now_timestamp
def _now_timestamp():
"""
@return: UTC timestamp suitable for indicating when a publish completed
@rtype: str
"""
now = dateutils.now_utc_datetime_with_tzinfo()
now_in_iso_format = dateutils.format_iso8601_datetime(now)
return now_in_iso_format
示例6: add_result
def add_result(repo_id, offset):
started = dateutils.now_utc_datetime_with_tzinfo()
completed = started + datetime.timedelta(days=offset)
r = RepoSyncResult.expected_result(
repo_id, 'foo', 'bar', dateutils.format_iso8601_datetime(started),
dateutils.format_iso8601_datetime(completed), 1, 1, 1, '', '',
RepoSyncResult.RESULT_SUCCESS)
RepoSyncResult.get_collection().save(r, safe=True)
示例7: migrate
def migrate(*args, **kwargs):
"""
Make sure last_updated field is set for every distributor.
"""
updated_key = 'last_updated'
collection = get_collection('repo_distributors')
for distributor in collection.find():
if distributor.get(updated_key) is None:
distributor[updated_key] = dateutils.now_utc_datetime_with_tzinfo()
collection.save(distributor)
示例8: update_last_unit_removed
def update_last_unit_removed(repo_id):
"""
Updates the UTC date record on the repository for the time the last unit was removed.
:param repo_id: identifies the repo
:type repo_id: str
"""
repo_obj = model.Repository.objects.get_repo_or_missing_resource(repo_id)
repo_obj.last_unit_removed = dateutils.now_utc_datetime_with_tzinfo()
repo_obj.save()
示例9: pre_save
def pre_save(cls, sender, document, **kwargs):
"""
The signal that is triggered before importer is saved.
:param sender: class of sender (unused)
:type sender: object
:param document: mongoengne document being saved
:type document: pulp.server.db.model.Importer
"""
document.last_updated = dateutils.now_utc_datetime_with_tzinfo()
示例10: pre_save_signal
def pre_save_signal(cls, sender, document, **kwargs):
"""
The signal that is triggered before distributor is saved.
:param sender: sender class
:type sender: object
:param document: Document that sent the signal
:type document: Distributor
"""
document.last_updated = dateutils.now_utc_datetime_with_tzinfo()
示例11: _now_timestamp
def _now_timestamp():
"""
Return a current timestamp in iso8601 format.
:return: iso8601 UTC timestamp with timezone specified.
:rtype: str
"""
now = dateutils.now_utc_datetime_with_tzinfo()
now_in_iso_format = dateutils.format_iso8601_datetime(now)
return now_in_iso_format
示例12: test_last_publish
def test_last_publish(self):
# Setup
self.publish_manager.publish(self.group_id, self.distributor_id)
# Test
last_publish = self.publish_manager.last_publish(self.group_id, self.distributor_id)
# Verify
now = dateutils.now_utc_datetime_with_tzinfo()
difference = now - last_publish
self.assertTrue(difference.seconds < 2)
示例13: migrate
def migrate(*args, **kwargs):
"""
Add last_updated to the distributor collection.
"""
key = 'last_updated'
collection = get_collection('repo_distributors')
for distributor in collection.find():
if key in distributor.keys():
continue
elif 'last_publish' in distributor.keys():
distributor[key] = distributor['last_publish']
else:
distributor[key] = dateutils.now_utc_datetime_with_tzinfo()
collection.save(distributor)
示例14: _set_current_date_on_field
def _set_current_date_on_field(repo_id, field_name):
"""
Updates the UTC date record the given field to the current UTC time.
:param repo_id: identifies the repo
:type repo_id: str
:param field_name: field to update
:type field_name: str
"""
spec = {'id': repo_id}
operation = {'$set': {field_name: dateutils.now_utc_datetime_with_tzinfo()}}
repo_coll = Repo.get_collection()
repo_coll.update(spec, operation, safe=True)
示例15: migrate
def migrate(*args, **kwargs):
"""
Add last_updated and last_override_config to the importer collection.
"""
updated_key = 'last_updated'
config_key = 'last_override_config'
collection = get_collection('repo_importers')
for importer in collection.find():
if config_key not in importer.keys():
importer[config_key] = {}
if updated_key in importer.keys():
continue
elif 'last_sync' in importer.keys():
importer[updated_key] = dateutils.parse_iso8601_datetime(importer['last_sync'])
else:
importer[updated_key] = dateutils.now_utc_datetime_with_tzinfo()
collection.save(importer)