#!/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.ServerKeyPath = None self.ClientKeyPath = 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 'serverkeypath' == key: self.ServerKeyPath = config['serverkeypath'] elif 'clientkeypath' == key: self.ClientKeyPath = config['clientkeypath'] 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.ServerKeyPath is None: sys.stderr.write('No server-key-path configuration found!') sys.exit(-1) if self.ClientKeyPath is None: sys.stderr.write('No client-key-path configuration found!') sys.exit(-1)