forked from babafeng/ApktoolInstall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
executable file
·65 lines (52 loc) · 2.07 KB
/
install.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
import os
import shutil
import platform
VERSION = "v1.0"
def install_apktool():
system = platform.system()
print("I: Apktool Install %s." % VERSION)
print("I: System: %s." % system)
if system == "Linux":
try:
shutil.copyfile(os.path.abspath("apktool_2.2.0.jar"), "/usr/bin/apktool.jar")
print("I: Copy [apktool_2.2.0.jar] to [/usr/bin/] successed.")
except Exception as err:
print("E: %s." % err)
print("E: Failed.")
return
try:
shutil.copyfile(os.path.abspath("apktool"), "/usr/bin/apktool")
print("I: Copy [apktool] to [/usr/bin/] successed.")
except Exception as err:
print("E: %s." % err)
print("E: Failed.")
return
p = os.popen("sudo chmod 755 /usr/bin/apktool.jar")
p = os.popen("sudo chmod 755 /usr/bin/apktool")
p.read()
print("I: Done.")
elif system == "Windows":
try:
shutil.copyfile(os.path.abspath("apktool_2.2.0.jar"), "C:\\Windows\\System32\\apktool.jar")
print("I: Copy [apktool_2.2.0.jar] to [C:\\Windows\\System32] successed.")
except Exception as err:
print("E: %s." % err)
print("E: Failed.")
return
apktool_cmd_text = """@echo off\nset PATH=%CD%;%PATH%;\njava -jar "%~dp0\\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9"""
try:
with open("C:\\Windows\\System32\\apktool.cmd", "w") as apktool_cmd_file:
apktool_cmd_file.write(apktool_cmd_text)
apktool_cmd_file.close()
except Exception as err:
print("E: %s." % err)
finally:
if os.path.exists("C:\\Windows\\System32\\apktool.cmd"):
print("I: Create [apktool.cmd] successed.")
else:
print("E: Create [apktool.cmd] failed.")
print("E: Failed.")
return
print("I: Done.")
if __name__ == '__main__':
install_apktool()