-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.py
executable file
·40 lines (36 loc) · 1.15 KB
/
start.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
#!/usr/bin/python3
import os
from os.path import exists, expanduser
import sys
def get_log_path():
try:
home_folder = expanduser("~")
config_location = home_folder + "/.config/workoutPlan.conf"
stream = open(config_location, "r")
if exists(config_location):
log_path = home_folder + stream.readline().strip("LOGPATH=~")
return log_path
except FileNotFoundError as e:
sys.exit("No config file found to determine LOGPATH")
def select_option():
prompt = "1. Choose\n2. Time\n3. Log\n4. History\n5. Catalog\n6. Quit\nSelect step: "
option = str(input(prompt))
script_path = get_log_path().replace("log/", "").strip("\n")
script_dict = {
"1":"1-choose.py", "2":"2-time.py", "3":"3-log.py", "4":"history.py",
"5":"history.py abc"
}
if option in script_dict:
invoke_script = script_path + script_dict[option]
os.system('python3 ' + invoke_script)
return "Y"
elif option == "6":
return "N"
else:
print("Invalid Option\n")
return "Y"
#Invoke function
ask_again = (select_option())
#Ask user to provide input again, if input is not proper
while ask_again != "N":
ask_again = (select_option())