#!/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

        # 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'])

        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)
