-
Notifications
You must be signed in to change notification settings - Fork 2
/
extract.py
executable file
·72 lines (58 loc) · 1.99 KB
/
extract.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
#!/usr/bin/env python
import sys
import os
import glob
import shutil
import logging
################################################################################
# Logging
################################################################################
logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
################################################################################
# Globals
################################################################################
SCRIPTS = [
"./xiaomi/qualcomm/extracttas.py",
"./xiaomi/mediatek/extracttas.py",
"./samsung/qualcomm/extracttas.py",
"./samsung/kinibi/extracttas.py",
"./samsung/teegris/extracttas.py",
"./other_vendors/vivo/mtk_kinibi_extracttas.py",
"./other_vendors/vivo/qc_extracttas.py",
"./other_vendors/transsien/mtk_bp_extracttas.py",
"./other_vendors/oppo/mtk_kinibi_extracttas.py",
"./other_vendors/oppo/qc_extracttas.py",
]
################################################################################
# Code
################################################################################
def main(image_path: str, out_dir: str):
for script in SCRIPTS:
log.info(f"Trying {script}")
shutil.rmtree(out_dir)
os.mkdir(out_dir)
cmd = f"{script} -t -f {image_path} -o {out_dir}"
status = os.system(cmd)
success = False
for path in (glob.glob(f"{out_dir}/*/tas/*") + glob.glob(f"{out_dir}/tas/*")):
log.info(f"Current path: {path}")
if os.path.isfile(path):
success = True
break
if success:
log.info(f"Success with {script}")
break
def usage():
print(f"{sys.argv[0]} <image> <out_dir>")
if __name__ == "__main__":
if len(sys.argv) != 3:
usage()
exit(1)
image_path = sys.argv[1]
out_dir = sys.argv[2]
if not os.path.isfile(image_path):
usage()
exit(1)
main(image_path, out_dir)