-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-loader.py
More file actions
70 lines (62 loc) · 1.84 KB
/
app-loader.py
File metadata and controls
70 lines (62 loc) · 1.84 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
from fileinput import filename
def menu():
while True:
print("########## Python App loader ##########")
print("1: Run all Apps")
print("2: Add App")
print("3: Read App paths")
print("4: Exit")
print("#######################################")
choice=int(input("Enter your choice : "))
if choice == 1:
run()
elif choice == 2:
add()
elif choice == 3:
read()
elif choice == 4:
quit()
else:
print("Invalid Input")
menu()
def run():
if os.path.isfile('app-paths'):
if os.path.getsize('app-paths') > 0:
count = 0
with open("app-paths") as file_read:
while True:
count += 1
line = file_read.readline()
if not line:
break
os.startfile(line.strip())
print("Running : "+line.strip())
else: print ("File empty!")
else: print("File not exist")
def add():
app_path=(input("Add app path : "))
if os.path.isfile("app-paths"):
with open("app-paths", "a+") as file_append:
file_append.seek(0)
data = file_append.read(100)
if len(data) > 0 :
file_append.write("\n")
file_append.write(app_path)
else:
with open("app-paths","w+") as file_write:
file_write.write(app_path)
print("Path Added!")
def read():
count = 0
with open("app-paths") as file_read:
while True:
count += 1
line = file_read.readline()
if not line:
break
print("{}: {}".format(count, line.strip()))
def main():
menu()
if __name__ == "__main__":
main()