-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
48 lines (36 loc) · 953 Bytes
/
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
import os
PATH = os.getcwd()
def getScript(PATH) :
rep = []
for file in os.listdir(PATH) :
if (".sh" in file and not file[:2] == "__") :
rep.append(file)
return rep
def display(listScript) :
print("Made your choice : ")
print("('exit' for exit)\n")
for index,scriptPath in enumerate(listScript) :
scriptName = "".join(scriptPath.split(".")[:-1])
print(f"\t {index} <--> {scriptName}")
execute = lambda name : os.system("./"+name)
def tryParse(s):
try:
int(s)
return True
except ValueError:
return False
def getNumber(listScript) :
choice = ""
while True :
choice = input("\n<insert number> : ")
if (choice == "exit") :
return
if (not tryParse(choice) or int(choice) >= len(listScript)) :
print(f"'{choice}' : Invalid Input")
choice = ""
else :
execute(listScript[int(choice)])
listScript = getScript(PATH)
sorted(listScript)
display(listScript)
getNumber(listScript)