forked from Lemonzhulixin/python-appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseIosPhone.py
More file actions
81 lines (64 loc) · 2.41 KB
/
BaseIosPhone.py
File metadata and controls
81 lines (64 loc) · 2.41 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
68
69
70
71
72
73
74
75
76
77
78
79
import subprocess
import os
'''
获取ios下的硬件信息
'''
def get_ios_devices():
devices = []
result = subprocess.Popen("ideviceinfo -k UniqueDeviceID", shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.readlines()
for item in result:
t = item.decode().split("\n")
if len(t) >= 2:
devices.append(t[0])
return devices
def get_ios_version(duid):
command = "ideviceinfo -u %s -k ProductVersion" % duid
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.readlines()
for item in result:
t = item.decode().split("\n")
if len(t) >= 2:
return t[0]
def get_ios_product_name(duid):
command = "ideviceinfo -u %s -k DeviceName" % duid
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.readlines()
for item in result:
t = item.decode().split("\n")
if len(t) >= 2:
return t[0]
def get_ios_product_type(duid):
command = "ideviceinfo -u %s -k ProductType" % duid
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.readlines()
for item in result:
t = item.decode().split("\n")
if len(t) >= 2:
return t[0]
def get_ios_product_os(duid):
command = "ideviceinfo -u %s -k ProductName" % duid
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.readlines()
for item in result:
t = item.decode().split("\n")
if len(t) >= 2:
return t[0]
def get_ios_PhoneInfo(duid):
name = get_ios_product_name(duid)
release = get_ios_version(duid)
type = get_ios_product_type(duid)
result = {"release": release, "device": name, "duid": duid, "type": type}
return result
#编译facebook的wda到真机
def build_wda_ios(duid):
os.popen(
"xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=" + duid + " test")
if __name__ == '__main__':
dev_list = []
devices = get_ios_devices()
for i in range(len(devices)):
duid = get_ios_devices()[i]
dev = get_ios_PhoneInfo(duid)
dev_list.append(dev)
print(dev_list)