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


Python Cache.get_scenario_sessions_information方法代码示例

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


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

示例1: get

# 需要导入模块: from stubo.cache import Cache [as 别名]
# 或者: from stubo.cache.Cache import get_scenario_sessions_information [as 别名]
    def get(self, scenario_name):
        """

        Returns scenario name, current sessions and their states,
        stub count, total, document size. Also, provides direct URL link to stub list.
        :param scenario_name: <string> scenario name

        Response JSON:
        {
            "stubs": 32,
             "space_used_kb": 840,
             "recorded": "2015-07-15",
             "name": "localhost:scenario_16",
             "scenarioRef": "/stubo/api/v2/scenarios/objects/localhost:scenario_16"
         }
        """

        # check if hostname is supplied - if not, override scenario name with new value
        scenario_name = _get_scenario_full_name(self, scenario_name)
        # query MongoDB
        document = yield self.db.scenario.find_one({'name': scenario_name})

        # form a result dictionary
        if document is not None:
            # get stub count
            stub_count = yield self.db.scenario_stub.find({'scenario': scenario_name}).count()
            # get size
            scenario_cl = Scenario()
            size = scenario_cl.size(scenario_name)
            # check if size is None
            if size is None:
                size = 0
            recorded = scenario_cl.recorded(scenario_name)
            if recorded is None:
                recorded = '-'

            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)

            result_dict = {'name': scenario_name,
                           'stub_count': stub_count,
                           'recorded': recorded,
                           'space_used_kb': int(size),
                           'scenarioRef': '/stubo/api/v2/scenarios/objects/{0}'.format(scenario_name),
                           'sessions': sessions}
            self.set_status(200)
            self.write(result_dict)
        else:
            self.send_error(404)
开发者ID:JohnFDavenport,项目名称:mirage,代码行数:55,代码来源:handlers.py


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