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


Python CallRequest.serialize方法代码示例

本文整理汇总了Python中pulp.server.dispatch.call.CallRequest.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python CallRequest.serialize方法的具体用法?Python CallRequest.serialize怎么用?Python CallRequest.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.server.dispatch.call.CallRequest的用法示例。


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

示例1: test_serialize_deserialize

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import serialize [as 别名]
 def test_serialize_deserialize(self):
     args = ["fee", "fie", "foe", "foo"]
     kwargs = {"one": "foo", "two": "bar", "three": "baz"}
     call_request = CallRequest(function, args, kwargs)
     data = call_request.serialize()
     self.assertTrue(isinstance(data, dict))
     call_request_2 = CallRequest.deserialize(data)
     self.assertTrue(isinstance(call_request_2, CallRequest), str(type(call_request_2)))
开发者ID:jlsherrill,项目名称:pulp,代码行数:10,代码来源:test_dispatch_call.py

示例2: test_serialize_deserialize_with_execution_hook

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import serialize [as 别名]
 def test_serialize_deserialize_with_execution_hook(self):
     key = dispatch_constants.CALL_CANCEL_LIFE_CYCLE_CALLBACK
     call_request = CallRequest(function)
     call_request.add_life_cycle_callback(key, function)
     data = call_request.serialize()
     self.assertTrue(isinstance(data, dict))
     call_request_2 = CallRequest.deserialize(data)
     self.assertTrue(isinstance(call_request_2, CallRequest))
     self.assertTrue(call_request_2.execution_hooks[key][0] == function)
开发者ID:jlsherrill,项目名称:pulp,代码行数:11,代码来源:test_dispatch_call.py

示例3: test_serialize_deserialize_with_control_hook

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import serialize [as 别名]
 def test_serialize_deserialize_with_control_hook(self):
     key = dispatch_constants.CALL_CANCEL_CONTROL_HOOK
     call_request = CallRequest(function)
     call_request.add_control_hook(key, function)
     data = call_request.serialize()
     self.assertTrue(isinstance(data, dict))
     call_request_2 = CallRequest.deserialize(data)
     self.assertTrue(isinstance(call_request_2, CallRequest))
     self.assertTrue(call_request_2.control_hooks[key] == function)
开发者ID:jlsherrill,项目名称:pulp,代码行数:11,代码来源:test_dispatch_call.py

示例4: _insert_scheduled_v2_repo

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import serialize [as 别名]
    def _insert_scheduled_v2_repo(self, repo_id, schedule):
        importer_id = ObjectId()
        schedule_id = ObjectId()

        importer_doc = {'importer_id': importer_id,
                        'importer_type_id': yum_repos.YUM_IMPORTER_TYPE_ID,
                        'scheduled_syncs': [str(schedule_id)]}
        self.tmp_test_db.database.repo_importers.update({'repo_id': repo_id}, {'$set': importer_doc}, safe=True)

        call_request = CallRequest(sync_with_auto_publish_itinerary, [repo_id], {'overrides': {}})
        interval, start, recurrences = dateutils.parse_iso8601_interval(schedule)
        scheduled_call_doc = {'_id': schedule_id,
                              'id': str(schedule_id),
                              'serialized_call_request': call_request.serialize(),
                              'schedule': schedule,
                              'failure_threshold': None,
                              'consecutive_failures': 0,
                              'first_run': start or datetime.datetime.utcnow(),
                              'next_run': None,
                              'last_run': None,
                              'remaining_runs': recurrences,
                              'enabled': True}
        scheduled_call_doc['next_run'] = all_repos._calculate_next_run(scheduled_call_doc)
        self.tmp_test_db.database.scheduled_calls.insert(scheduled_call_doc, safe=True)
开发者ID:domcleal,项目名称:pulp,代码行数:26,代码来源:test_db_all_repos.py

示例5: _sync_schedules

# 需要导入模块: from pulp.server.dispatch.call import CallRequest [as 别名]
# 或者: from pulp.server.dispatch.call.CallRequest import serialize [as 别名]
def _sync_schedules(v1_database, v2_database, report):
    v1_repo_collection = v1_database.repos
    v2_repo_importer_collection = v2_database.repo_importers
    v2_scheduled_call_collection = v2_database.scheduled_calls

    # ugly hack to find out which repos have already been scheduled
    # necessary because $size is not a meta-query and doesn't support $gt, etc
    repos_without_schedules = v2_repo_importer_collection.find(
        {'scheduled_syncs': {'$size': 0}}, fields=['repo_id'])

    repo_ids_without_schedules = [r['repo_id'] for r in repos_without_schedules]

    repos_with_schedules = v2_repo_importer_collection.find(
        {'repo_id': {'$nin': repo_ids_without_schedules}}, fields=['repo_id'])

    repo_ids_with_schedules = [r['repo_id'] for r in repos_with_schedules]

    repos_to_schedule = v1_repo_collection.find(
        {'id': {'$nin': repo_ids_with_schedules}, 'sync_schedule': {'$ne': None}},
        fields=['id', 'sync_schedule', 'sync_options', 'last_sync'])

    for repo in repos_to_schedule:

        if repo['id'] not in repo_ids_without_schedules:
            report.error('Repository [%s] not found in the v2 database.'
                         'sync scheduling being canceled.' % repo['id'])
            return False

        args = [repo['id']]
        kwargs = {'overrides': {}}
        call_request = CallRequest(sync_with_auto_publish_itinerary, args, kwargs, principal=SystemUser())

        scheduled_call_document = {
            '_id': ObjectId(),
            'id': None,
            'serialized_call_request': None,
            'schedule': repo['sync_schedule'],
            'failure_threshold': None,
            'consecutive_failures': 0,
            'first_run': None,
            'last_run': None,
            'next_run': None,
            'remaining_runs': None,
            'enabled': True}

        scheduled_call_document['id'] = str(scheduled_call_document['_id'])

        schedule_tag = resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, scheduled_call_document['id'])
        call_request.tags.append(schedule_tag)

        scheduled_call_document['serialized_call_request'] = call_request.serialize()

        if isinstance(repo['sync_options'], dict):
            scheduled_call_document['failure_threshold'] = repo['sync_options'].get('failure_threshold', None)

        interval, start, recurrences = dateutils.parse_iso8601_interval(scheduled_call_document['schedule'])

        scheduled_call_document['first_run'] = start or datetime.utcnow()
        scheduled_call_document['remaining_runs'] = recurrences
        scheduled_call_document['next_run'] = _calculate_next_run(scheduled_call_document)

        if repo['last_sync'] is not None:
            scheduled_call_document['last_run'] = dateutils.to_naive_utc_datetime(dateutils.parse_iso8601_datetime(repo['last_sync']))

        v2_scheduled_call_collection.insert(scheduled_call_document, safe=True)
        v2_repo_importer_collection.update({'repo_id': repo['id']},
                                           {'$push': {'scheduled_syncs': scheduled_call_document['id']}},
                                           safe=True)

    return True
开发者ID:bartwo,项目名称:pulp,代码行数:72,代码来源:all_repos.py


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