def _get_device_id ( self , bus ) : _dbus = bus . get ( SERVICE_BUS , PATH ) devices = _dbus . devices ( ) if self . device is None and self . device_id is None and len ( devices ) == 1 : return devices [ 0 ] for id in devices : self . _dev = bus . get ( SERVICE_BUS , DEVICE_PATH + "/%s" % id ) if self . device == self . _dev . name : return id return None
get usb device id python
Find the device id
def _get_device_id(self, bus):
        """
        Find the device id
        """
        _dbus = bus.get(SERVICE_BUS, PATH)
        devices = _dbus.devices()

        if self.device is None and self.device_id is None and len(devices) == 1:
            return devices[0]

        for id in devices:
            self._dev = bus.get(SERVICE_BUS, DEVICE_PATH + "/%s" % id)
            if self.device == self._dev.name:
                return id

        return None