-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
53 lines (44 loc) · 2.36 KB
/
generate.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
import subprocess
import sys
if __name__ == '__main__':
number_of_arguments = len(sys.argv)
if number_of_arguments == 1:
print("No arguments passed. Please pass which version of installer you want to generate [script/interface].")
print("Example: python generate.py interface")
sys.exit(1)
elif number_of_arguments == 2:
version = sys.argv[1]
pyinstaller_command = "python -m PyInstaller --onefile --icon=resources/images/minelabs-logo.ico" \
" --add-data resources/*.json;resources "
try:
# Run PyInstaller as a subprocess
if version == "interface":
pyinstaller_command += "interface_version.py --name Minelabs-Setup --noconsole" \
" --add-data resources/maps/vAlpha/*.zip;resources/maps/vAlpha\ " \
"--add-data resources/maps/vLatest/*.zip;resources/maps/vLatest\\" \
" --add-data resources/images/*;resources/images"
subprocess.run(pyinstaller_command, check=True)
elif version == "script":
data_versions = {
"alpha": "resources/maps/vAlpha/*.zip;resources/maps/vAlpha\\",
"latest": "resources/maps/vLatest/*.zip;resources/maps/vLatest\\"
}
r_version = "alpha"
pyinstaller_command += f"script_version.py --name Minelabs-installer-{r_version} --add-data " \
f"{data_versions[r_version]}"
subprocess.run(pyinstaller_command, check=True)
else:
print(
"Invalid version. Please pass which version of installer you want to generate [script/interface].")
print("Example: python generate.py interface")
sys.exit(1)
print("PyInstaller operation completed successfully.")
except subprocess.CalledProcessError as e:
print("PyInstaller operation failed. Error:", e)
except Exception as e:
print("An unexpected error occurred:", e)
else:
print(
"Too many arguments passed. Please pass which version of installer you want to generate [script/interface].")
print("Example: python generate.py interface")
sys.exit(1)