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


Python Stub.space_used方法代码示例

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


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

示例1: get_session_status

# 需要导入模块: from stubo.model.stub import Stub [as 别名]
# 或者: from stubo.model.stub.Stub import space_used [as 别名]
def get_session_status(handler, all_hosts=True):
    scenario = Scenario()
    host_scenarios = {}
    for s in scenario.get_all():
        host, scenario_name = s['name'].split(':')
        if not all_hosts and get_hostname(handler.request)  != host:
            continue
        if host not in host_scenarios:
            host_scenarios[host] = {}
        sessions = []
        cache = Cache(host)
        for session_name, session in cache.get_sessions(scenario_name):
            # try and get the last_used from the last tracker get/response
            # else when the begin/session playback was called
            last_used = session_last_used(s['name'], session_name, 'playback')
            if last_used:
                last_used = last_used['start_time'].strftime('%Y-%m-%d %H:%M:%S')
            else:
                # session has never been used for playback 
                last_used = session.get('last_used', '-')
            session['last_used'] =  last_used  
            sessions.append(session)   
        stub_counts =  stub_count(host, scenario_name)['data']['count']
        recorded = '-'
        space_used = 0
        if sessions:
            if stub_counts:
                stubs = list(get_stubs(host, scenario_name))
                recorded =  max(x['stub'].get('recorded') for x in stubs)   
                for stub in stubs:
                    stub = Stub(stub['stub'], s['name']) 
                    space_used += stub.space_used()             
                host_scenarios[host][scenario_name] = (sessions, stub_counts, 
                                            recorded, human_size(space_used)) 
            else:
                host_scenarios[host][scenario_name] = (sessions, 0, '-', 0)        
    return host_scenarios  
开发者ID:JohnFDavenport,项目名称:stubo-app,代码行数:39,代码来源:api.py


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