-
Notifications
You must be signed in to change notification settings - Fork 24
/
main.py
68 lines (52 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import getopt
import sys
import multiprocessing
from wfhelper import WFHelperWrapper
from utils import adbUtil, configUtil, Log
from server import Server
if __name__ == "__main__":
# 不写这个打包exe会出问题
multiprocessing.freeze_support()
isDebug = False
serial = None
config = None
instance = None
port = 8080
try:
_opts, args = getopt.getopt(sys.argv[1:], "-t-s:-d:-c:-p:-n")
opts = dict(_opts) # type: Dict[str,str]
if "-t" in opts:
isDebug = True
if "-s" in opts:
savePath = opts["-s"]
adbUtil.setDevice(adbUtil.selectSerial())
adbUtil.getScreen(savePath)
Log.info("截图保存至 : {}".format(savePath))
sys.exit()
if "-d" in opts:
serial = opts["-d"]
if "-c" in opts:
config = configUtil.getConfig(opts["-c"])
if "-n" in opts:
if serial is None:
serial = adbUtil.selectSerial()
if config is None:
config = configUtil.selectConfig()
instance = WFHelperWrapper(serial, config)
if "-p" in opts:
port = opts["-p"]
Log.info("use port : {}".format(opts["-p"]))
# TODO -v 参数打印log信息
except getopt.GetoptError:
Log.error("参数错误")
sys.exit()
# FIXME 为避免其他使用者造成疑惑,当前版本默认创建实例并给出警告
if instance is None:
Log.warning("脚本将在未来版本中取消默认启动任务并在UI中统一管理,如有需要请使用 -n 指令")
if serial is None:
serial = adbUtil.selectSerial()
if config is None:
config = configUtil.selectConfig()
instance = WFHelperWrapper(serial, config)
server = Server(instance, isDebug, port)
server.run()