예제 #1
0
    def __init__(self, message_render, with_cold=True):
        self.message_render = message_render
        self.logger = logging.getLogger()

        # Inicialize
        self.bus = dbus.SystemBus()

        obj = self.bus.get_object('org.freedesktop.Hal',
                                  '/org/freedesktop/Hal/Manager')

        self.hal_manager = dbus.Interface(obj, 'org.freedesktop.Hal.Manager')

        self.hal_manager.connect_to_signal('DeviceAdded', self.on_device_added)
        self.hal_manager.connect_to_signal('DeviceRemoved',
                                           self.on_device_removed)

        self.udi_dict = {}
        self.modify_handler_dict = {}
        self.devicelist = DeviceList()

        self.__init_actors()

        if with_cold:
            coldplug = ColdPlugListener(self)
            coldplug.start()

        self.logger.info("DeviceListener iniciado")
예제 #2
0
    def __init__(self, message_render, with_cold=True):
        """
        [es] Registramos el monitor de cambios en el hardware y lo conectamos
             a las señales del bus que alertan de la conexión o desconexión de
             dispositivos.
             Parametros:
                 message_render: interfaz a la que enviar las notificaciones
                 with_cold: booleano para indicar si se lanza el Monitor
                            de dispositivos conectados en frio
        -----------------------------------------------------------------------
        [en] Register the device listener and attaches it to the corresponding
             bus signals that alert about devices connection or discnnection.
             Params:
                 message_render: interface for sending notifications through
                 with_cold: boolean indicating wether we launch the Cold Plug 
                            Listener
        """
        self.message_render = message_render
        self.logger = logging.getLogger()

        self.bus = dbus.SystemBus()

        obj = self.bus.get_object('org.freedesktop.Hal',
                                  '/org/freedesktop/Hal/Manager')

        self.hal_manager = dbus.Interface(obj, 'org.freedesktop.Hal.Manager')

        self.hal_manager.connect_to_signal('DeviceAdded', self.on_device_added)
        self.hal_manager.connect_to_signal('DeviceRemoved',
                                           self.on_device_removed)

        self.udi_dict = {}
        self.modify_handler_dict = {}
        self.devicelist = DeviceList()

        self.__init_actors()

        if with_cold:
            coldplug = ColdPlugListener(self)
            coldplug.start()

        self.logger.info(_("Device Listener started"))