generated from CursedPrograms/Python-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
56 lines (45 loc) · 1.86 KB
/
main.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
import os
import subprocess
import json
def main():
with open('config.json') as json_file:
config_data = json.load(json_file)
# Get the project name from the JSON data
app_name = config_data.get('Config', {}).get('AppName', 'default_app')
# Print the actual app name value
print(app_name)
scripts = {
"1": {
"name": "Run 'trainer.py'",
"description": "Run the gennhausser trainer",
"file_name": "scripts/trainer.py"
},
"00": {
"name": "Run 'install_dependencies.py'",
"description": "Install dependencies",
"file_name": "scripts/install_dependencies.py"
},
}
current_script_dir = os.path.dirname(os.path.abspath(__file__))
while True:
print("\nAvailable Scripts:")
for key, script_info in scripts.items():
print(f"{key}: {script_info['name']} - {script_info['description']}")
user_choice = input("Enter the number of the script you want to run (or 'q' to quit): ").strip()
if user_choice == 'q':
break
if user_choice in scripts:
selected_script = scripts[user_choice]
script_file_name = selected_script["file_name"]
script_file_path = os.path.join(current_script_dir, script_file_name)
if os.path.exists(script_file_path):
try:
subprocess.run(["python", script_file_path])
except Exception as e:
print(f"An error occurred while running the script: {e}")
else:
print(f"Script file '{script_file_name}' does not exist.")
else:
print("Invalid choice. Please select a valid script number.")
if __name__ == "__main__":
main()