您可以直接在python中通过dbus使用Udisk。
import dbusbus = dbus.SystemBus()ud_manager_obj = bus.get_object("org.freedesktop.UDisks", "/org/freedesktop/UDisks")ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.UDisks')for dev in ud_manager.EnumerateDevices(): device_obj = bus.get_object("org.freedesktop.UDisks", dev) device_props = dbus.Interface(device_obj, dbus.PROPERTIES_IFACE) print device_props.Get('org.freedesktop.UDisks.Device', "DriveVendor") print device_props.Get('org.freedesktop.UDisks.Device', "DeviceMountPaths") print device_props.Get('org.freedesktop.UDisks.Device', "DriveSerial") print device_props.Get('org.freedesktop.UDisks.Device', "PartitionSize")
可用属性的完整列表在此处http://hal.freedesktop.org/docs/udisks/Device.html
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)