-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcellphone
executable file
·84 lines (66 loc) · 1.98 KB
/
cellphone
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
#!/usr/bin/env python3
import os
import sys
import time
import cmd
import json
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is True for "yes" or False for "no".
"""
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
if default is None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)
while True:
sys.stdout.write(question + prompt)
choice = input().lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' "
"(or 'y' or 'n').\n")
def main():
script_path = os.path.dirname(__file__)
config_file_path = os.path.join(script_path, "config", "cell.json")
print("Module is in " + script_path)
print("cell.json is at " + config_file_path)
print("Reading configuration file...")
with open(config_file_path) as config:
content = config.read()
cell_locations = json.loads(content)
print("Constructing commands...")
commands = []
for loc in cell_locations:
commands.append("adb pull -a " + loc + " .")
os.system("clear")
print("Done. adb devices shows")
os.system("adb devices")
print("The following will be executed (files copied to cwd):")
for index, cmd in enumerate(commands, start=1):
print(str(index) + ": " + cmd)
print("You are in directory " + os.getcwd() + ".")
if query_yes_no("Happy?"):
print("Executing commands...")
for cmd in commands:
print(cmd)
os.system(cmd)
print("Finished.")
exit(0)
else:
print("Aborted.")
exit(1)
if __name__ == '__main__':
main()