-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathrepack.py
78 lines (61 loc) · 2.08 KB
/
repack.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
#!/usr/bin python3
from configparser import ConfigParser
import shutil
import os
import stat
import subprocess
import webbrowser
_ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
def readonly_handler(func, path, execinfo):
# or os.chmod(path, stat.S_IWRITE) from "stat" module
os.chmod(path, stat.S_IWRITE)
func(path)
def rmtree(path):
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path, onerror=readonly_handler)
else:
os.remove(path)
def repack():
config = ConfigParser()
config.read("setup.cfg")
version = config.get("version_info", "version")
print("version: " + version)
download_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
zippath = os.path.join(download_dir, "TTDeDroid_%s.7z"%(version))
destdir = os.path.abspath(os.path.join(download_dir, 'TTDeDroid'))
print("start copy dir:")
rmtree(zippath)
rmtree(destdir)
shutil.copytree(_ROOT_PATH, destdir)
# subprocess.call("cp -r %s %s"%(_ROOT_PATH, destdir), shell=True)
os.chdir(destdir)
rmtree(".git")
rmtree("sources")
rmtree("cache")
rmtree("dist")
rmtree("build")
rmtree(".vscode")
rmtree(".history")
rmtree("__pycache__")
rmtree('.DS_Store')
if os.path.exists(zippath):
os.remove(zippath)
print("7z a %s %s"%(zippath, os.path.join(destdir, '*')))
subprocess.call("7z a %s %s"%(zippath, os.path.join(destdir, '*')))
if os.path.exists(zippath):
print("zip file pack done")
def build_executable_file():
os.chdir(_ROOT_PATH)
subprocess.call("pyinstaller -F showjar.py", shell=True)
if os.path.exists("bin/showjar.bat"):
os.rename("bin/showjar.bat", "bin/bak_showjar.bat")
if os.path.exists("bin/bak_showjar.exe"):
os.remove("bin/bak_showjar.exe")
shutil.copyfile("dist/showjar.exe", "bin/showjar.exe")
def upload_to_mirror():
webbrowser.open_new_tab('https://gitee.com/tp7309/ReleaseRepo/tree/master/TTDeDroid')
if __name__ == '__main__':
build_executable_file()
repack()
upload_to_mirror()