Ejemplo n.º 1
0
 def get_upnp_client(self):
     """Get a referance to the UPnPClient intance."""
     if self._upnp_client == None:
         task_runner = self._get_task_runner()
         from Tribler.UPnP.upnpclient import UPnPClient
         self._upnp_client = UPnPClient(task_runner, logger=_LOGGER)
         # Wrap close method
         self._real_client_close = self._upnp_client.close
         self._upnp_client.close = self._wrap_client_close
     return self._upnp_client
    def __init__(self):

        self._task_runner = TaskRunner()
        self._server = UPnPServer(self._task_runner,
                            SERVER_PRODUCT_NAME,
                            SERVER_ROOT_DEVICE_CONFIG)
        self._client = UPnPClient(self._task_runner)

        # Add a couple of services
        self._server.add_service(SwitchPower("SwitchPower"))
        self._server.add_service(URLService("URLService"))
        self._server.add_service(BookmarkService())

        # Console Namespace
        namespace = {}
        namespace['S'] = self._server
        namespace['C'] = self._client

        self._console = ObjectConsole(self, namespace,
                                      run="_run",
                                      stop="_stop",
                                      name="UPnP")