Skip to content

Commit 908016d

Browse files
committedAug 5, 2018
init update
1 parent c0b7cfa commit 908016d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
 

‎Battery.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def get_battery(devices):
2+
cmd = "adb -s " + devices + " shell dumpsys battery"
3+
print(cmd)
4+
output = subprocess.check_output(cmd).split()
5+
stderr=subprocess.PIPE).stdout.readlines()
6+
st = ".".join([x.decode() for x in output]) # 转换为string
7+
print(st)
8+
battery2 = int(re.findall("level:.(\d+)*", st, re.S)[0])
9+
writeInfo(battery2, PATH("../info/" + devices + "_battery.pickle"))
10+
return battery2

‎GPRS.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def get_flow(pid, type, devices):
2+
# pid = get_pid(pkg_name)
3+
_flow1 = [[], []]
4+
if pid is not None:
5+
cmd = "adb -s " + devices + " shell cat /proc/" + pid + "/net/dev"
6+
print(cmd)
7+
_flow = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
8+
stderr=subprocess.PIPE).stdout.readlines()
9+
for item in _flow:
10+
if type == "wifi" and item.split()[0].decode() == "wlan0:": # wifi
11+
# 0 上传流量,1 下载流量
12+
_flow1[0].append(int(item.split()[1].decode()))
13+
_flow1[1].append(int(item.split()[9].decode()))
14+
print("------flow---------")
15+
print(_flow1)
16+
break
17+
if type == "gprs" and item.split()[0].decode() == "rmnet0:": # gprs
18+
print("-----flow---------")
19+
_flow1[0].append(int(item.split()[1].decode()))
20+
_flow1[1].append(int(item.split()[9].decode()))
21+
print(_flow1)
22+
break
23+
else:
24+
_flow1[0].append(0)
25+
_flow1[1].append(0)

0 commit comments

Comments
 (0)