extend the configuration for the UI communication

此提交包含在:
Sven Czarnian
2021-11-11 11:05:41 +01:00
父節點 9c9e7dd445
當前提交 014ea5fa0a
共有 2 個檔案被更改,包括 48 行新增0 行删除

30
aman/com/WebUI.py 一般檔案
查看文件

@@ -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.PortReceiver = None
self.PortNotification = None
self.WebUiUrl = None
self.WebUiSequenceNotification = None
self.WebUiConfigurationReceiver = None
# search the required sections
for key in config:
@@ -17,6 +20,12 @@ class Server():
self.PortReceiver = int(config['portreceiver'])
elif 'portnotification' == key:
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:
sys.stderr.write('No server-address configuration found!')
@@ -27,3 +36,12 @@ class Server():
if self.PortNotification is None:
sys.stderr.write('No server-port-notification configuration found!')
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)