From 86b25083c61c583c866c8bbb93c18cf3c8f57804 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Mon, 3 Aug 2009 15:16:32 -0400 Subject: No longer use HAL in list-harddrives. --- command-stubs/list-harddrives-stub | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/command-stubs/list-harddrives-stub b/command-stubs/list-harddrives-stub index a8060b15b..ae7e31dba 100755 --- a/command-stubs/list-harddrives-stub +++ b/command-stubs/list-harddrives-stub @@ -18,43 +18,17 @@ # along with this program. If not, see . # -import dbus import sys - -HAL_INTERFACE = "org.freedesktop.Hal" -HAL_MANAGER_PATH = "/org/freedesktop/Hal/Manager" -HAL_MANAGER_INTERFACE = "org.freedesktop.Hal.Manager" -HAL_DEVICE_INTERFACE = "org.freedesktop.Hal.Device" +import parted def main(argv): lst = set() - try: - bus = dbus.SystemBus() - hal = dbus.Interface(bus.get_object(HAL_INTERFACE, - HAL_MANAGER_PATH), - HAL_MANAGER_INTERFACE) - except: - sys.exit(1) - - for udi in hal.FindDeviceByCapability("volume"): - try: - haldev = dbus.Interface(bus.get_object(HAL_INTERFACE, udi), - HAL_DEVICE_INTERFACE) - props = haldev.GetAllProperties() - except dbus.exceptions.DBusException: - continue - - if not props.has_key('volume.size'): - continue - - size = str(props['volume.size'] / (1024 * 1024)) - if props.has_key('block.device'): - devnode = props['block.device'].encode('utf-8') - elif props.has_key('linux.device_file'): - devnode = props['linux.device_file'].encode('utf-8') + for dev in filter(lambda d: d.type <= parted.DEVICE_SX8, parted.getAllDevices()): + disk = parted.Disk(dev) - lst.add("%s %s" % (devnode, size,)) + for part in disk.partitions: + lst.add("%s %s" % (part.path, int(part.getSize()))) lst = list(lst) lst.sort() -- cgit