forked from Lemonzhulixin/python-appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseAndroidPhone.py
More file actions
68 lines (60 loc) · 2.09 KB
/
Copy pathBaseAndroidPhone.py
File metadata and controls
68 lines (60 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
import os
import subprocess
# 得到手机信息
def getPhoneInfo(devices):
cmd = "adb -s " + devices +" shell cat /system/build.prop "
# print(cmd)
# phone_info = os.popen(cmd).readlines()
phone_info = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.readlines()
release = "ro.build.version.release=" # 版本
model = "ro.product.model=" #型号
brand = "ro.product.brand=" # 品牌
device = "ro.product.device=" # 设备名
result = {"release": release, "model": model, "brand": brand, "device": device}
for line in phone_info:
for i in line.split():
temp = i.decode()
if temp.find(release) >= 0:
result["release"] = temp[len(release):]
break
if temp.find(model) >= 0:
result["model"] = temp[len(model):]
break
if temp.find(brand) >= 0:
result["brand"] = temp[len(brand):]
break
if temp.find(device) >= 0:
result["device"] = temp[len(device) :]
break
# print(result)
return result
# 得到最大运行内存
def get_men_total(devices):
cmd = "adb -s "+devices+ " shell cat /proc/meminfo"
get_cmd = os.popen(cmd).readlines()
men_total = 0
men_total_str = "MemTotal"
for line in get_cmd:
if line.find(men_total_str) >= 0:
men_total = line[len(men_total_str) +1:].replace("kB", "").strip()
break
return int(men_total)
# 得到几核cpu
def get_cpu_kel(devices):
cmd = "adb -s " +devices +" shell cat /proc/cpuinfo"
get_cmd = os.popen(cmd).readlines()
find_str = "processor"
int_cpu = 0
for line in get_cmd:
if line.find(find_str) >= 0:
int_cpu += 1
return str(int_cpu) + "核"
# 得到手机分辨率
def get_app_pix(devices):
result = os.popen("adb -s " + devices+ " shell wm size", "r")
return result.readline().split("Physical size:")[1]
if __name__=="__main__":
pass
t = getPhoneInfo("4ed397ac")
print(t)