class UPnPServer: """This class implements an extensible UPnP Server.""" def __init__(self, task_runner, product_name, root_device_config=None, logger=None): # TaskRunner self._tr = task_runner # Logger self._logger = _Logger(logger) # Initalise Root Device if not root_device_config: self._root_device_config = DEFAULT_ROOT_DEVICE_CONFIG else: self._root_device_config = root_device_config device = upnpdevice.UPnPDevice(self._root_device_config) device.set_is_root(True) # Event Dispatcher (HTTP Client) self._ed = EventDispatcher(self._tr, logger=self._logger) # HTTP Server self._http_server = HTTPServer(self._tr, logger=self._logger) # SSDP Server self._ssdp_server = SSDPServer(self._tr, logger=self._logger) # ServiceManager (The Core) self._sm = ServiceManager(self._tr, self._ssdp_server, self._http_server, self._ed, device, product_name, logger=self._logger) # Export Service Manager API self.add_service = self._sm.add_service self.get_service = self._sm.get_service self.get_service_ids = self._sm.get_service_ids # Export Internals self.get_root_device = self._sm.get_root_device # Startup done by TaskRunner self._tr.add_task(self._sm.startup) def get_presentation_url(self): root = self.get_root_device() return root.base_url + root.get_presentation_url() def announce(self): """Causes underlying SSDPServer to re-announce itself.""" self._tr.add_task(self._ssdp_server.announce) def close(self): """Close the UPnP server.""" self._sm.close() self._ssdp_server.close() self._http_server.close() self._ed.close()
def __init__(self, task_runner, product_name, root_device_config=None, logger=None): # TaskRunner self._tr = task_runner # Logger self._logger = _Logger(logger) # Initalise Root Device if not root_device_config: self._root_device_config = DEFAULT_ROOT_DEVICE_CONFIG else: self._root_device_config = root_device_config device = upnpdevice.UPnPDevice(self._root_device_config) device.set_is_root(True) # Event Dispatcher (HTTP Client) self._ed = EventDispatcher(self._tr, logger=self._logger) # HTTP Server self._http_server = HTTPServer(self._tr, logger=self._logger) # SSDP Server self._ssdp_server = SSDPServer(self._tr, logger=self._logger) # ServiceManager (The Core) self._sm = ServiceManager(self._tr, self._ssdp_server, self._http_server, self._ed, device, product_name, logger=self._logger) # Export Service Manager API self.add_service = self._sm.add_service self.get_service = self._sm.get_service self.get_service_ids = self._sm.get_service_ids # Export Internals self.get_root_device = self._sm.get_root_device # Startup done by TaskRunner self._tr.add_task(self._sm.startup)
def __init__(self, region='eu-west-1', profile=None, access_key=None, secret_key=None): ''' Initialization and configuration of the client Args: region (str): Region in which to make queries and operations. profile (str): Name of the AWS profile set in ~/.aws/credentials file access_key (str): API access key of your AWS account secret_key (str): API secret key of your AWS account Returns: None ''' self.aws = ServiceManager(region, profile=profile, access_key=access_key, secret_key=secret_key)
def Service(name): if not ServiceManager.is_initialized: ServiceManager.load_all() return ServiceManager.fetch_service(name)