Browse Source

Added scan.py, which is a hack to help retrieve the devices

configuration in order to write the settings
master
Andrea Luzzardi 18 years ago
parent
commit
8e8d92cc61
1 changed files with 55 additions and 0 deletions
  1. +55
    -0
      pam_usb/tools/scan.py

+ 55
- 0
pam_usb/tools/scan.py View File

@ -0,0 +1,55 @@
#!/usr/bin/env python2.4
import dbus
bus = dbus.SystemBus()
halService = bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
halManager = dbus.Interface(halService, 'org.freedesktop.Hal.Manager')
def getStorageDevice(udi):
for child in halManager.FindDeviceByCapability('storage'):
deviceObj = bus.get_object('org.freedesktop.Hal',
child)
deviceProperties = deviceObj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device')
if deviceProperties['storage.physical_device'] == udi + '_if0':
return child
return None
def showVolumes(udi):
for volume in halManager.FindDeviceByCapability('volume'):
deviceObj = bus.get_object('org.freedesktop.Hal',
volume)
deviceProperties = deviceObj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device')
if deviceProperties['block.storage_device'] != udi:
continue
print '%s\t\t%s' % (deviceProperties['block.device'],
deviceProperties['volume.uuid'])
def showProperties(udi):
storage = getStorageDevice(udi)
if storage is None:
return
print
deviceObj = bus.get_object('org.freedesktop.Hal',
udi)
deviceProperties = deviceObj.GetAllProperties(
dbus_interface = 'org.freedesktop.Hal.Device')
print 'Device %s' % udi
print 'Serial Number: %s' % deviceProperties['usb_device.serial']
print
print 'Volume\t\t\tUUID'
showVolumes(storage)
bus = dbus.SystemBus()
halService = bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
halManager = dbus.Interface(halService, 'org.freedesktop.Hal.Manager')
print 'Scanning USB devices...'
for udi in halManager.FindDeviceStringMatch('info.bus', 'usb_device'):
deviceObj = bus.get_object('org.freedesktop.Hal',
udi)
showProperties(udi)

Loading…
Cancel
Save