def __init__(self, conf=None): ''' Initializes daemon by starting and configuring a server. :param conf: A path to a daemon configuration file :type conf: string ''' if conf is not None: if os.path.isfile(conf): config.update('daemon', conf) else: log.warning("Configuration file %s does not exist." " Skipped" % conf) port = config.getInt('daemon', 'connection', 'port') ip = config.get('daemon', 'connection', 'address') if ip is None: log.warning("No attribute IP in daemon configuration file. " "Using default value %s" % DEFAULT_IP) config.set('daemon', 'connection', 'address', DEFAULT_IP) ip = DEFAULT_IP if port is None: log.warning("No attribute port in daemon configuration file. " "Using default value %d" % DEFAULT_PORT) config.set('daemon', 'connection', 'port', DEFAULT_PORT) port = DEFAULT_PORT server.Server.__init__(self, (ip, port)) info = protocol.create(protocol.MSG_TYPE_RESPONSE, protocol.MSG_TARGET_SYSTEM, protocol.MSG_NAME_INFO, version=config.VERSION, locale=(locale.getdefaultlocale()[0] or ''), extensions=protocol.getExtensions(), status=True) self._infoData = info.marshal()
def extensions(self): ''' Gets a list of protocol extensions supported by the device. :return: A list of protocol extensions :rtype: tuple ''' if not self._info: return [] return [ext for ext in protocol.getExtensions() if ext in self._info.extensions]
def extensions(self): ''' Gets a list of protocol extensions supported by the device. :return: A list of protocol extensions :rtype: tuple ''' if not self._info: return [] return [ ext for ext in protocol.getExtensions() if ext in self._info.extensions ]
def testGetExtensions(self): self.failUnless( _TestProtocolExtension.name in protocol.getExtensions())
def testGetExtensions(self): self.failUnless(_TestProtocolExtension.name in protocol.getExtensions())