Browse Source

Improved the volume detection code

Andrea Luzzardi 17 years ago
parent
commit
f6eb057a64
1 changed files with 3 additions and 9 deletions
  1. +3
    -9
      tools/pamusb-conf

+ 3
- 9
tools/pamusb-conf View File

@ -24,7 +24,6 @@ from xml.dom import minidom
class Device: class Device:
def __init__(self, udi): def __init__(self, udi):
self.__udi = udi self.__udi = udi
self.__findStorageDevice()
deviceObj = bus.get_object('org.freedesktop.Hal', deviceObj = bus.get_object('org.freedesktop.Hal',
udi) udi)
deviceProperties = deviceObj.GetAllProperties( deviceProperties = deviceObj.GetAllProperties(
@ -47,13 +46,6 @@ class Device:
return True return True
return self.__isChildOfDevice(properties['info.parent']) return self.__isChildOfDevice(properties['info.parent'])
def __findStorageDevice(self):
for child in halManager.FindDeviceByCapability('storage'):
if self.__isChildOfDevice(child):
self.__storageUdi = child
return
raise Exception, '%s is not a storage device.' % self.__udi
def __repr__(self): def __repr__(self):
return "%s %s (%s)" % (self.vendor, self.product, self.serialNumber) return "%s %s (%s)" % (self.vendor, self.product, self.serialNumber)
@ -64,7 +56,9 @@ class Device:
volume) volume)
deviceProperties = deviceObj.GetAllProperties( deviceProperties = deviceObj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device') dbus_interface = 'org.freedesktop.Hal.Device')
if deviceProperties['block.storage_device'] != self.__storageUdi:
if deviceProperties['block.major'] != 8:
continue
if not self.__isChildOfDevice(volume):
continue continue
vols.append({'uuid' : deviceProperties['volume.uuid'], vols.append({'uuid' : deviceProperties['volume.uuid'],
'device' : deviceProperties['block.device']}) 'device' : deviceProperties['block.device']})


Loading…
Cancel
Save