Server.py 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python
  2. import configparser;
  3. import sys
  4. class Server():
  5. def __init__(self, config : configparser.ConfigParser):
  6. self.Address = None
  7. self.PortReceiver = None
  8. self.PortNotification = None
  9. # search the required sections
  10. for key in config:
  11. if 'address' == key:
  12. self.Address = config['address']
  13. elif 'portreceiver' == key:
  14. self.PortReceiver = int(config['portreceiver'])
  15. elif 'portnotification' == key:
  16. self.PortNotification = int(config['portnotification'])
  17. if self.Address is None:
  18. sys.stderr.write('No server-address configuration found!')
  19. sys.exit(-1)
  20. if self.PortReceiver is None:
  21. sys.stderr.write('No server-port-receiver configuration found!')
  22. sys.exit(-1)
  23. if self.PortNotification is None:
  24. sys.stderr.write('No server-port-notification configuration found!')
  25. sys.exit(-1)