forked from HenryLeinen/mcdu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
85 lines (72 loc) · 1.95 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
from mcdu.core import MCDU
from mcdu.acars import ACARS
from mcdu.atc import ATC
from mcdu.network import ACARS_API
from mcdu.display import myDisplay
from mcdu.s_data import DATA
from mcdu.s_init import INIT
from mcdu.database import Database
from mcdu.s_f_plan import FPLAN
from mcdu.s_perf import PERF
import os, sys
try:
from configparser import SafeConfigParser
except ImportError:
from ConfigParser import SafeConfigParser
def run():
config = SafeConfigParser()
config.read("config/defaults.cfg")
config.read("~/.config/mcdu.cfg")
config.read("config/mcdu.cfg")
sim = config.get("General", "sim")
if sim == "fsx":
from mcdu.fsx import FSXReceiver
receiver = FSXReceiver()
elif sim == "xplane":
from mcdu.xplane import XPlaneReceiver
receiver = XPlaneReceiver()
else:
print("no simulator set")
return 1
db = Database()
receiver.start()
api = ACARS_API(config.get("ACARS", "logon"))
acars = ACARS(api)
atc = ATC(api)
data = DATA(api)
init = INIT(api)
fplan = FPLAN(api)
perf = PERF(api)
mcdu = MCDU()
mcdu.subsystem_register(acars)
mcdu.subsystem_register(atc)
mcdu.subsystem_register(data)
mcdu.subsystem_register(init)
mcdu.subsystem_register(fplan)
mcdu.subsystem_register(perf)
mcdu.database_register(db)
mcdu.menu()
application = myDisplay()
port = config.getint("General", "port")
application.initialize(mcdu)
application.open()
try:
print("running on port %i" % port)
# Call my application here
application.mainloop()
# receiver.run()
except KeyboardInterrupt:
print("quitting...")
except Exception:
import traceback
traceback.print_exc()
print("quitting...")
finally:
receiver.stop()
acars.stop()
atc.stop()
return 0
if __name__ == "__main__":
r = run()
sys.exit(r)