This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
run.py
90 lines (72 loc) · 2.19 KB
/
run.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/local/bin/python
# -*- coding:utf-8 -*-
"""
@author: valor
@file: run.py
@time: 2018/11/1 14:22
"""
import sys
import getopt
import platform
from main import Main
def run(argv):
if 0 == len(argv):
tips()
sys.exit(0)
try:
opts, args = getopt.getopt(argv, "hdP:s:", ["help"])
except getopt.GetoptError as e:
tips()
print("Error:", e)
sys.exit(1)
# check all params
o = []
p = []
for opt, param in opts:
o.append(opt)
p.append(param)
# show usage
if "-h" in o or "--help" in o:
usages()
sys.exit(0)
# Execute this script with default configuration
if "-d" in o:
fun = Main()
fun.main()
sys.exit(0)
# Execute this script binding the port and the device of adb.
if "-P" in o and "-s" in o:
print("Ps")
fun = Main(port=p[o.index("-P")], device=p[o.index("-s")])
fun.main()
sys.exit(0)
# Execute this script binding the port of adb.
if "-P" in o:
fun = Main(port=p[o.index("-P")])
fun.main()
sys.exit(0)
# Execute this script binding the device of adb.
if "-s" in o:
fun = Main(device=p[o.index("-s")])
fun.main()
sys.exit(0)
def tips():
print("Tip: please use '-h' or '--help' to view the usage."
"\n"
" -> 'python run.py -h' or 'python run.py --help'")
def usages():
print("Auto add wechat friends python script.\n"
"\n"
"usage: python run.py [arguments] Execute this script. Arguments is must existed.\n"
"\n"
"Arguments:\n"
" -h or --help Print Help (this message) and exit. Opposite other command.\n"
" -d Execute this script with default configuration. Opposite other command.\n"
" -P Execute this script binding the port of adb.\n"
" -s Execute this script binding the device of adb."
)
if __name__ == '__main__':
if platform.python_version() < str(3.3):
print("Requires python version greater than 3.3")
sys.exit(1)
run(sys.argv[1:])