#!/usr/bin/env python import configparser; import sys class Server(): def __init__(self, config : configparser.ConfigParser): 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: if 'address' == key: self.Address = config['address'] elif 'portreceiver' == key: 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!') sys.exit(-1) if self.PortReceiver is None: sys.stderr.write('No server-port-receiver configuration found!') sys.exit(-1) 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)