class Server(Service): """ def __init__(self, config, db): self._ip = config.ip self._port = config.port self._db = db self._running = False """ def __init__(self, ip, port, info_dict, db): self._ip = ip self._port = int(port) self._db = db self._info_dict = info_dict # to be passed to the zeroconf part self._zeroconf_service = ZeroconfService(self._info_dict) self._running = False print(ip, port, ) def start(self): """Start the service. Blocking call.""" #print('SERVER: Starting') self._server = _ServerImpl(self._ip, self._port, self._db) self._zeroconf_service.register() self._running = True def stop(self): """Stop the service. Blocking call.""" #print('SERVER: Stopping') self._zeroconf_service.unregister() self._server.shutdown() self._running = False #print('SERVER: Stopped') @property def status(self): """A string with information about the service""" print(''.join(['Server status: Running: ', str(self._running), ' (', self._ip, ':', str(self._port), ')'])) @property def running(self): """Returns True if the service is running, False otherwise""" return self._running