forked from lokidokicoki/fuel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·67 lines (57 loc) · 1.51 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
63
64
65
66
67
#!/usr/bin/python3
import pdb
import getopt, sys, datetime, sqlite3, string, time, math
import dbi
import functions as FN
from cli.cli import CLI
#from gtk.gui import GUI
from operator import itemgetter
debug = False
def usage():
print('Usage: fuel.py [options]')
print('-c, --cli use command line interface [default]')
#print('-g, --gtk use gtk gui')
print('-h, --help print this message and exit')
print('-d, --debug turn on debug mode, extra output, no saving')
def main():
'''
load record data
load vehicle data
show main menu
'''
global debug, gui
guiType = 0
try:
opts, args = getopt.getopt(sys.argv[1:], "hdcg", ["help", "debug", "cli", "gtk"])
except getopt.GetoptError as err:
# print help information and exit:
print(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
for o,a in opts:
if o in ("-d", "--debug"):
debug=True
elif o in ("-c", "--cli"):
guiType = 0
elif o in ("-g", "--gtk"):
guiType = 1
elif o in ("-h", "--help"):
usage()
exit()
else:
assert False, "unhandled option"
if debug:
print('#### DEBUG MODE ####')
if guiType == 0:
gui = CLI()
# elif guiType == 1:
# gui = GUI()
FN.load()
for v in FN.vehicles:
FN.fuel_graph(v)
FN.ppl_graph()
FN.index()
gui.start()
#call main
if __name__ == "__main__":
main()