python-获取app流量

2017-01-01 10:46
def getFlow(pid="31586"):
    flow_info = os.popen("adb shell cat /proc/"+pid+"/net/dev").readlines()
    t = []
    for info in flow_info:
        temp_list = info.split()
        t.append(temp_list)
    flow[0].append(ceil(int(t[6][1])/1024)) # 下载
    flow[1].append(ceil(int(t[6][9])/1024)) # 发送
    return fl