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

Python dateutils.now_utc_datetime_with_tzinfo函数代码示例

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

本文整理汇总了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函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:jeremycline,项目名称:pulp,代码行数:26,代码来源:test_model.py


示例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)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:7,代码来源:test_dateutils.py


示例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
开发者ID:beav,项目名称:pulp,代码行数:7,代码来源:test_sync.py


示例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)
开发者ID:credativ,项目名称:pulp,代码行数:8,代码来源:test_publish.py


示例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
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:8,代码来源:publish.py


示例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)
开发者ID:beav,项目名称:pulp,代码行数:8,代码来源:test_sync.py


示例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)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:10,代码来源:0028_distributor_last_updated_fix.py


示例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()
开发者ID:zjhuntin,项目名称:pulp,代码行数:10,代码来源:repository.py


示例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()
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:10,代码来源:__init__.py


示例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()
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:10,代码来源:__init__.py


示例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
开发者ID:zjhuntin,项目名称:pulp,代码行数:10,代码来源:repository.py


示例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)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:11,代码来源:test_publish.py


示例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)
开发者ID:darinlively,项目名称:pulp,代码行数:14,代码来源:0024_distributor_last_updated.py


示例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)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:15,代码来源:cud.py


示例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)
开发者ID:pcreech,项目名称:pulp,代码行数:19,代码来源:0025_importer_schema_change.py


示例16: migrate

def migrate(*args, **kwargs):
    """
    Add last_updated and last_override_config to the distributor collection.
    """
    updated_key = 'last_updated'
    config_key = 'last_override_config'
    collection = get_collection('repo_distributors')
    for distributor in collection.find():
        if config_key not in distributor.keys():
            distributor[config_key] = {}

        if updated_key in distributor.keys():
            continue
        elif 'last_publish' in distributor.keys():
            distributor[updated_key] = distributor['last_publish']
        else:
            distributor[updated_key] = dateutils.now_utc_datetime_with_tzinfo()

        collection.save(distributor)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:19,代码来源:0024_distributor_schema_change.py


示例17: test_import_uploaded_unit

    def test_import_uploaded_unit(self, mock_repo_qs, mock_rebuild):
        importer_controller.set_importer('repo-u', 'mock-importer', {})

        key = {'key': 'value'}
        metadata = {'k1': 'v1'}
        timestamp_pre_upload = dateutils.now_utc_datetime_with_tzinfo()

        mock_repo = mock_repo_qs.get_repo_or_missing_resource.return_value
        importer_return_report = {'success_flag': True, 'summary': '', 'details': {}}
        mock_plugins.MOCK_IMPORTER.upload_unit.return_value = importer_return_report

        upload_id = self.upload_manager.initialize_upload()
        file_path = self.upload_manager._upload_file_path(upload_id)

        fake_user = model.User('import-user', '')
        manager_factory.principal_manager().set_principal(principal=fake_user)

        response = self.upload_manager.import_uploaded_unit('repo-u', 'mock-type', key, metadata,
                                                            upload_id)

        # import_uploaded_unit() should have returned our importer_return_report
        self.assertTrue(response is importer_return_report)

        call_args = mock_plugins.MOCK_IMPORTER.upload_unit.call_args[0]
        self.assertTrue(call_args[0] is mock_repo.to_transfer_repo())
        self.assertEqual(call_args[1], 'mock-type')
        self.assertEqual(call_args[2], key)
        self.assertEqual(call_args[3], metadata)
        self.assertEqual(call_args[4], file_path)

        conduit = call_args[5]
        self.assertTrue(isinstance(conduit, UploadConduit))
        self.assertEqual(call_args[5].repo_id, 'repo-u')

        # It is now platform's responsibility to update plugin content unit counts
        self.assertTrue(mock_rebuild.called, "rebuild_content_unit_counts must be called")

        # Make sure that the last_unit_added timestamp was updated
        self.assertTrue(mock_repo.last_unit_added > timestamp_pre_upload)

        # Clean up
        mock_plugins.MOCK_IMPORTER.upload_unit.return_value = None
        manager_factory.principal_manager().set_principal(principal=None)
开发者ID:alexxa,项目名称:pulp,代码行数:43,代码来源:test_upload.py


示例18: test_to_transfer_repo

    def test_to_transfer_repo(self):

        dt = dateutils.now_utc_datetime_with_tzinfo()
        data = {
            'id': 'foo',
            'display_name': 'bar',
            'description': 'baz',
            'notes': 'qux',
            'content_unit_counts': {'units': 1},
            'last_unit_added': dt,
            'last_unit_removed': dt
        }

        repo = to_transfer_repo(data)
        self.assertEquals('foo', 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)
开发者ID:credativ,项目名称:pulp,代码行数:21,代码来源:test_common.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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