generated from CursedPrograms/project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
62 lines (53 loc) · 2.11 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
57
58
59
60
61
62
import os
import subprocess
import json
def main():
with open('config.json') as json_file:
config_data = json.load(json_file)
app_name = config_data.get('Config', {}).get('AppName', 'default_app')
print(app_name)
scripts = {
"1": {
"name": "Run 'gender_age_predictor.py'",
"description": "Predicts gender and age.",
"file_name": "scripts/gender_age_predictor.py"
},
"2": {
"name": "Run 'gender_predictor.py'",
"description": "Predicts gender.",
"file_name": "scripts/gender_predictor.py"
},
"3": {
"name": "Run 'gender_age_predictor_webcam.py'",
"description": "Predicts gender from a webcam feed.",
"file_name": "scripts/gender_age_predictor_webcam.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()