forked from iOSRealRun/iOSRealRun-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (42 loc) · 1.45 KB
/
main.py
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
#!/usr/bin/env python3
"""
main.py
the entrance of the program
"""
import sys
import os
import tools.utils as utils
import tools.run as run
from tools.initialize import connect, init
from tools.config import config
if not os.path.exists("./log"):
os.mkdir("./log")
sys.stderr=open("./log/error.log", "w") # redirect error message
OS = utils.getOS() # get the OS, possible values: win, darwin, linux
# path separators for different systems
seperator = {"win": "\\", "darwin": "/", "linux": "/"} # path seperator
seperator = seperator[OS]
libimobiledeviceDir = config.libimobiledeviceDir + seperator + OS # path to libimobiledevice
v = config.v # simulate speed, unit: m/s
# environment variables
env = { # environment variables for library
"win": None,
"darwin": {"DYLD_LIBRARY_PATH": os.getcwd() + "/" + libimobiledeviceDir},
"linux": {"LD_LIBRARY_PATH": os.getcwd() + "/" + libimobiledeviceDir}
}
# connect to the device and mount DevelopDiskImage
connect()
loc = init() # get the route
print("路线信息读取成功")
if OS == "win":
utils.setDisplayRequired()
print("已开始模拟跑步, 速度大约为 {} m/s".format(str(v)))
print("会无限绕圈,要停可以按Ctrl+C")
print("请勿直接关闭窗口,否则无法还原正常定位")
try:
run.run(loc, v)
finally:
utils.resetLoc() # reset the location
if OS == "win":
utils.resetDisplayRequired()
print("现在你可以关闭当前窗口或终端了")