Browse Source

Better device detection code

master
Andrea Luzzardi 17 years ago
parent
commit
c6a36963b9
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      pam_usb/tools/pamusb-conf

+ 13
- 5
pam_usb/tools/pamusb-conf View File

@ -33,13 +33,21 @@ class Device:
self.product = deviceProperties['info.product'] self.product = deviceProperties['info.product']
self.serialNumber = deviceProperties['usb_device.serial'] self.serialNumber = deviceProperties['usb_device.serial']
def __isChildOfDevice(self, udi):
obj = bus.get_object('org.freedesktop.Hal', udi)
properties = obj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device')
if not properties.has_key('info.parent'):
return False
if properties.has_key('info.bus') and properties['info.bus'] == 'usb_device':
return False
if properties['info.parent'] == self.__udi:
return True
return self.__isChildOfDevice(properties['info.parent'])
def __findStorageDevice(self): def __findStorageDevice(self):
for child in halManager.FindDeviceByCapability('storage'): for child in halManager.FindDeviceByCapability('storage'):
obj = bus.get_object('org.freedesktop.Hal',
child)
properties = obj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device')
if properties['storage.physical_device'] == self.__udi + '_if0':
if self.__isChildOfDevice(child):
self.__storageUdi = child self.__storageUdi = child
return return
raise Exception, '%s is not a storage device.' % self.__udi raise Exception, '%s is not a storage device.' % self.__udi


Loading…
Cancel
Save