-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (44 loc) · 1.75 KB
/
main.py
File metadata and controls
53 lines (44 loc) · 1.75 KB
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 os
import subprocess
def main():
print("Python Project")
scripts = {
"1": {
"name": "Run 'Script00'",
"description": "This is Script01",
"file_name": "scripts/script00.py"
},
"2": {
"name": "Run 'Script01",
"description": "This is Script01",
"file_name": "scripts/script01.py"
},
"00": {
"name": "Run 'Install Dependencies'",
"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()