I'm using python-dbus
to interface with HAL, and I need to find a device's UDI based on it's path in the /dev
hierarchy.
So given a path such as /dev/sdb
, I want to get a value back like /org/freedesktop/Hal/devices/usb_device_10
.
Pure python solution:
import dbus
bus = dbus.SystemBus()
obj = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
iface = dbus.Interface(obj, "org.freedesktop.Hal.Manager")
print iface.FindDeviceStringMatch("block.device", "/dev/sda")