本文整理汇总了Python中stubo.model.db.Scenario.stub_counts方法的典型用法代码示例。如果您正苦于以下问题:Python Scenario.stub_counts方法的具体用法?Python Scenario.stub_counts怎么用?Python Scenario.stub_counts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stubo.model.db.Scenario
的用法示例。
在下文中一共展示了Scenario.stub_counts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from stubo.model.db import Scenario [as 别名]
# 或者: from stubo.model.db.Scenario import stub_counts [as 别名]
def get(self):
"""
Returns a list with all scenarios (and URL paths to these resources),
stub count
"""
# getting all scenarios
cursor = self.db.scenario.find()
# sorting based on name
cursor.sort([('name', pymongo.ASCENDING)])
# get size
scenario_cl = Scenario()
scenarios_sizes = scenario_cl.size()
scenarios_recorded = scenario_cl.recorded()
scenarios_stub_counts = scenario_cl.stub_counts()
# start mapping data
scenarios = []
result_dict = {}
while (yield cursor.fetch_next):
document = cursor.next_object()
try:
# getting information about recorded, sizes and stub counts
scenario_recorded = scenarios_recorded.get(document['name'], '-')
scenario_size = int(scenarios_sizes.get(document['name'], 0))
scenario_stub_count = scenarios_stub_counts.get(document['name'], 0)
scenario_name = document['name']
host, scenario = scenario_name.split(':')
# getting session data
sessions = []
cache = Cache(host)
for session_info in cache.get_scenario_sessions_information(scenario):
sessions.append(session_info)
scenarios.append({'name': scenario_name,
'recorded': scenario_recorded,
'space_used_kb': scenario_size,
'stub_count': scenario_stub_count,
'sessions': sessions,
'scenarioRef': '/stubo/api/v2/scenarios/objects/%s' % document['name']})
except KeyError:
log.warn('Scenario name not found for object: %s' % document['_id'])
result_dict['data'] = scenarios
self.set_status(200)
self.write(result_dict)