extend the configuration for the UI communication
This commit is contained in:
30
aman/com/WebUI.py
Normal file
30
aman/com/WebUI.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from aman.config.Server import Server
|
||||||
|
from aman.types.Inbound import Inbound
|
||||||
|
|
||||||
|
class WebUI:
|
||||||
|
def __init__(self):
|
||||||
|
self.Config = None
|
||||||
|
self.Aman = None
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.release()
|
||||||
|
|
||||||
|
def acquire(self, config : Server, aman):
|
||||||
|
self.Config = config
|
||||||
|
self.Aman = aman
|
||||||
|
|
||||||
|
def release(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
def sendSequence(self, airport, inbounds):
|
||||||
|
sequence = []
|
||||||
|
|
||||||
|
for inbound in inbounds:
|
||||||
|
sequence.append(str(inbound.toJSON()))
|
||||||
|
|
||||||
|
# TODO send to the server
|
||||||
|
#print(json.dumps({ 'airport': airport, 'sequence': sequence }, ensure_ascii=True))
|
||||||
@@ -8,6 +8,9 @@ class Server():
|
|||||||
self.Address = None
|
self.Address = None
|
||||||
self.PortReceiver = None
|
self.PortReceiver = None
|
||||||
self.PortNotification = None
|
self.PortNotification = None
|
||||||
|
self.WebUiUrl = None
|
||||||
|
self.WebUiSequenceNotification = None
|
||||||
|
self.WebUiConfigurationReceiver = None
|
||||||
|
|
||||||
# search the required sections
|
# search the required sections
|
||||||
for key in config:
|
for key in config:
|
||||||
@@ -17,6 +20,12 @@ class Server():
|
|||||||
self.PortReceiver = int(config['portreceiver'])
|
self.PortReceiver = int(config['portreceiver'])
|
||||||
elif 'portnotification' == key:
|
elif 'portnotification' == key:
|
||||||
self.PortNotification = int(config['portnotification'])
|
self.PortNotification = int(config['portnotification'])
|
||||||
|
elif 'webuiurl' == key:
|
||||||
|
self.WebUiUrl = config['webuiurl']
|
||||||
|
elif 'sequencenotification' == key:
|
||||||
|
self.WebUiSequenceNotification = config['sequencenotification']
|
||||||
|
elif 'configurationreceiver' == key:
|
||||||
|
self.WebUiConfigurationReceiver = config['configurationreceiver']
|
||||||
|
|
||||||
if self.Address is None:
|
if self.Address is None:
|
||||||
sys.stderr.write('No server-address configuration found!')
|
sys.stderr.write('No server-address configuration found!')
|
||||||
@@ -27,3 +36,12 @@ class Server():
|
|||||||
if self.PortNotification is None:
|
if self.PortNotification is None:
|
||||||
sys.stderr.write('No server-port-notification configuration found!')
|
sys.stderr.write('No server-port-notification configuration found!')
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
if self.WebUiUrl is None:
|
||||||
|
sys.stderr.write('No Web-UI URL configuration found!')
|
||||||
|
sys.exit(-1)
|
||||||
|
if self.WebUiSequenceNotification is None:
|
||||||
|
sys.stderr.write('No Web-UI sequence notification configuration found!')
|
||||||
|
sys.exit(-1)
|
||||||
|
if self.WebUiConfigurationReceiver is None:
|
||||||
|
sys.stderr.write('No Web-UI configuration receiver configuration found!')
|
||||||
|
sys.exit(-1)
|
||||||
|
|||||||
Reference in New Issue
Block a user