Exemplo n.º 1
0
class UPnPConsole:

    """This class wraps ObjectConsole to implement a 
    custom UPnP console."""

    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")


    def _run(self):
        """Run the TaskRunner."""
        self._task_runner.run_forever()

    def _stop(self):
        """
        Internal: Stop the UPnPClient, UPnPServer and the 
        TaskRunner.
        """
        self._client.close()
        self._server.close()
        self._task_runner.stop()

    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
class UPnPConsole:

    """This class wraps ObjectConsole to implement a
    custom UPnP console."""

    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")


    def _run(self):
        """Run the TaskRunner."""
        self._task_runner.run_forever()

    def _stop(self):
        """
        Internal: Stop the UPnPClient, UPnPServer and the
        TaskRunner.
        """
        self._client.close()
        self._server.close()
        self._task_runner.stop()

    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
Exemplo n.º 3
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")
Exemplo n.º 5
0
    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")