dbus/Hal code replacement
Mike Miller
dbuslist at mgmiller.net
Wed Dec 8 21:42:57 PST 2010
Hi,
A few years ago I wrote a script to grab disk info. It had the crappy
dbus/Hal code shown in the snippet below. I've just moved to a new
machine without Hal and the script no longer works of course.
I'm wondering if anyone here can help? How might I update this code?
It looks for the volume names of mounted disk volumes. I'm not very
familiar with dbus so would very much appreciate a few pointers. ;)
bus = dbus.SystemBus()
hal_manager_obj = bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal_manager_obj,
'org.freedesktop.Hal.Manager')
dbus_disks = {}
device_names = hal_manager.GetAllDevices()
for dev in device_names:
if dev.startswith('/org/freedesktop/Hal/devices/volume_'):
device_dbus_obj = bus.get_object('org.freedesktop.Hal', dev)
props = device_dbus_obj.GetAllProperties(dbus_interface=
'org.freedesktop.Hal.Device')
if props.has_key('block.device') and props.has_key('volume.label'):
blockdev = props['block.device'].split('/')[-1]
dbus_disks[blockdev] = props['volume.label']
-Mike
-------------------------------------------------------------
Mike Miller Earth, Sol, Orion Arm, Milky Way, VSC
More information about the dbus
mailing list