Exemplo n.º 1
0
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Client
        self._client = UPnPClient(self._task_runner)

        # Console Namespace
        name_space = {}
        name_space['get_device_uuids'] = self._client.get_device_uuids
        name_space['get_service_types'] = self._client.get_service_types
        name_space['get_service_ids'] = self._client.get_service_ids
        name_space['get_device'] = self._client.get_device
        name_space['get_services_by_type'] = self._client.get_services_by_type
        name_space['get_services_by_id'] = self._client.get_services_by_id
        name_space['get_services_by_short_id'] = \
            self._client.get_services_by_short_id
        name_space['get_service'] = self._client.get_service
        name_space['search'] = self._client.search

        self._console = ObjectConsole(self,
                                      name_space,
                                      run="_run",
                                      stop="_stop",
                                      name="UPnP Client")
Exemplo n.º 2
0
class UPnPServerConsole:

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

    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Server
        self._server = UPnPServer(self._task_runner, "Product 1.0")

        # Switch Power Service
        service_id = "SwitchPower"
        service = SwitchPower(service_id)
        self._server.add_service(service)

        # URL Service
        service_id_2 = "URLService"
        service_2 = URLService(service_id_2)
        self._server.add_service(service_2)

        # Bookmark Service
        service_3 = BookmarkService()
        self._server.add_service(service_3)

        # Console Namespace
        name_space = {}
        root_device = self._server.get_root_device()
        name_space[root_device.name] = root_device
        name_space[service_id] = service
        name_space[service_id_2] = service_2
        name_space[service_3.get_short_service_id()] = service_3
        name_space['add_service'] = self._server.add_service
        name_space['get_service'] = self._server.get_service
        name_space['get_services'] = self._server.get_service_ids
        name_space['announce'] = self._server.announce

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

    def _run(self):
        """Start TaskRunner."""
        self._task_runner.run_forever()

    def _stop(self):
        """Stop UPnPServer and TaskRunner"""
        self._server.close()
        self._task_runner.stop()


    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
Exemplo n.º 3
0
class UPnPServerConsole:
    """This class wraps ObjectConsole to implement a 
    custom console for UPnP server."""
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Server
        self._server = UPnPServer(self._task_runner, "Product 1.0")

        # Switch Power Service
        service_id = "SwitchPower"
        service = SwitchPower(service_id)
        self._server.add_service(service)

        # URL Service
        service_id_2 = "URLService"
        service_2 = URLService(service_id_2)
        self._server.add_service(service_2)

        # Bookmark Service
        service_3 = BookmarkService()
        self._server.add_service(service_3)

        # Console Namespace
        name_space = {}
        root_device = self._server.get_root_device()
        name_space[root_device.name] = root_device
        name_space[service_id] = service
        name_space[service_id_2] = service_2
        name_space[service_3.get_short_service_id()] = service_3
        name_space['add_service'] = self._server.add_service
        name_space['get_service'] = self._server.get_service
        name_space['get_services'] = self._server.get_service_ids
        name_space['announce'] = self._server.announce

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

    def _run(self):
        """Start TaskRunner."""
        self._task_runner.run_forever()

    def _stop(self):
        """Stop UPnPServer and TaskRunner"""
        self._server.close()
        self._task_runner.stop()

    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
Exemplo n.º 4
0
class UPnPClientConsole:

    """This class wraps ObjectConsole to implement a 
    custom console for UPnP Client (Control Point)."""

    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Client      
        self._client = UPnPClient(self._task_runner)
        
        # Console Namespace
        name_space = {}
        name_space['get_device_uuids'] = self._client.get_device_uuids
        name_space['get_service_types'] = self._client.get_service_types
        name_space['get_service_ids'] = self._client.get_service_ids
        name_space['get_device'] = self._client.get_device
        name_space['get_services_by_type'] = self._client.get_services_by_type
        name_space['get_services_by_id'] = self._client.get_services_by_id
        name_space['get_services_by_short_id'] = \
            self._client.get_services_by_short_id
        name_space['get_service'] = self._client.get_service
        name_space['search'] = self._client.search

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

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

    def _stop(self):
        """Stup UPnPClient and TaskRunner."""
        self._client.close()
        self._task_runner.stop()

    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
Exemplo n.º 5
0
class UPnPClientConsole:
    """This class wraps ObjectConsole to implement a
    custom console for UPnP Client (Control Point)."""
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Client
        self._client = UPnPClient(self._task_runner)

        # Console Namespace
        name_space = {}
        name_space['get_device_uuids'] = self._client.get_device_uuids
        name_space['get_service_types'] = self._client.get_service_types
        name_space['get_service_ids'] = self._client.get_service_ids
        name_space['get_device'] = self._client.get_device
        name_space['get_services_by_type'] = self._client.get_services_by_type
        name_space['get_services_by_id'] = self._client.get_services_by_id
        name_space['get_services_by_short_id'] = \
            self._client.get_services_by_short_id
        name_space['get_service'] = self._client.get_service
        name_space['search'] = self._client.search

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

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

    def _stop(self):
        """Stup UPnPClient and TaskRunner."""
        self._client.close()
        self._task_runner.stop()

    def run(self):
        """Runs the UPnP Console."""
        self._console.run()
Exemplo n.º 6
0
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Server
        self._server = UPnPServer(self._task_runner, "Product 1.0")

        # Switch Power Service
        service_id = "SwitchPower"
        service = SwitchPower(service_id)
        self._server.add_service(service)

        # URL Service
        service_id_2 = "URLService"
        service_2 = URLService(service_id_2)
        self._server.add_service(service_2)

        # Bookmark Service
        service_3 = BookmarkService()
        self._server.add_service(service_3)

        # Console Namespace
        name_space = {}
        root_device = self._server.get_root_device()
        name_space[root_device.name] = root_device
        name_space[service_id] = service
        name_space[service_id_2] = service_2
        name_space[service_3.get_short_service_id()] = service_3
        name_space['add_service'] = self._server.add_service
        name_space['get_service'] = self._server.get_service
        name_space['get_services'] = self._server.get_service_ids
        name_space['announce'] = self._server.announce

        self._console = ObjectConsole(self,
                                      name_space,
                                      run="_run",
                                      stop="_stop",
                                      name="UPnP Server")
Exemplo n.º 7
0
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Server
        self._server = UPnPServer(self._task_runner, "Product 1.0")

        # Switch Power Service
        service_id = "SwitchPower"
        service = SwitchPower(service_id)
        self._server.add_service(service)

        # URL Service
        service_id_2 = "URLService"
        service_2 = URLService(service_id_2)
        self._server.add_service(service_2)

        # Bookmark Service
        service_3 = BookmarkService()
        self._server.add_service(service_3)

        # Console Namespace
        name_space = {}
        root_device = self._server.get_root_device()
        name_space[root_device.name] = root_device
        name_space[service_id] = service
        name_space[service_id_2] = service_2
        name_space[service_3.get_short_service_id()] = service_3
        name_space['add_service'] = self._server.add_service
        name_space['get_service'] = self._server.get_service
        name_space['get_services'] = self._server.get_service_ids
        name_space['announce'] = self._server.announce

        self._console = ObjectConsole(self, name_space,
                                      run="_run",
                                      stop="_stop", name="UPnP Server")
Exemplo n.º 8
0
    def __init__(self):

        # Task Runner
        self._task_runner = TaskRunner()

        # UPnP Client      
        self._client = UPnPClient(self._task_runner)
        
        # Console Namespace
        name_space = {}
        name_space['get_device_uuids'] = self._client.get_device_uuids
        name_space['get_service_types'] = self._client.get_service_types
        name_space['get_service_ids'] = self._client.get_service_ids
        name_space['get_device'] = self._client.get_device
        name_space['get_services_by_type'] = self._client.get_services_by_type
        name_space['get_services_by_id'] = self._client.get_services_by_id
        name_space['get_services_by_short_id'] = \
            self._client.get_services_by_short_id
        name_space['get_service'] = self._client.get_service
        name_space['search'] = self._client.search

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