I want get the mount node of an usb mass-storage device, like /media/its-uuid in pyudev, class Device has some general attributes, but not uuid or mount node.
how to do it
t开发者_JAVA技巧hanks help
With pyudev, each device object provides a dictionary-like interface for its attributes. You can list them all with device.keys()
, e.g. UUID is for block devices is dev['ID_FS_UUID']
.
This will print the UUID of every USB flash disk currently plugged in along with its device node:
import pyudev
context = pyudev.Context()
for device in context.list_devices(subsystem='block', DEVTYPE='partition'):
if (device.get('ID_USB_DRIVER') == 'usb-storage'):
print '{0} {1}'.format(device.device_node, device.get('ID_FS_UUID'))
精彩评论