I retrieve the first device information from the block subsystem. For example that a USB stick was assigned to /dev/sdb. This is all the infos I can retrieve via the block subsystem:
[(u'DEVLINKS', u'/dev/disk/by-id/usb-Generic_Flash_Disk_63F2B6EC-0:0 /dev/disk/by-label/Fedora-Live-Desktop-x86_64-20-1 /dev/disk/by-path/pci-0000:00:1d.0-usb-0:1.2:1.0-scsi-0:0:0:0 /dev/disk/by-uu
id/2013-12-12-00-56-55-00'),
(u'DEVNAME', u'/dev/sdb'),
(u'DEVPATH', u'/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/host74/target74:0:0/74:0:0:0/block/sdb'),
(u'DEVTYPE', u'disk'), (u'ID_BUS', u'usb'),
(u'ID_FS_APPLICATION_ID', u'GENISOIMAGE\\x20ISO\\x209660\\x2fHFS\\x20FILESYSTEM\\x20CREATOR\\x20\\x28C\\x29\\x201993\\x20E.YOUNGDALE\\x20\\x28C\\x29\\x201997-2006\\x20J.PEARSON\\x2fJ.SCHILLING\\x20\\x28C\\x29\\x202006-2007\\x20CDRKIT\\x20TEAM'),
(u'ID_FS_BOOT_SYSTEM_ID', u'EL\\x20TORITO\\x20SPECIFICATION'),
(u'ID_FS_LABEL', u'Fedora-Live-Desktop-x86_64-20-1'),
(u'ID_FS_LABEL_ENC', u'Fedora-Live-Desktop-x86_64-20-1'),
(u'ID_FS_SYSTEM_ID', u'LINUX'),
(u'ID_FS_TYPE', u'iso9660'),
(u'ID_FS_USAGE', u'filesystem'),
(u'ID_FS_UUID', u'2013-12-12-00-56-55-00'),
(u'ID_FS_UUID_ENC', u'2013-12-12-00-56-55-00'),
(u'ID_FS_VERSION', u'Joliet Extension'),
(u'ID_INSTANCE', u'0:0'),
(u'ID_MODEL', u'Flash_Disk'),
(u'ID_MODEL_ENC', u'Flash\\x20Disk\\x20\\x20\\x20\\x20\\x20\\x20'),
(u'ID_MODEL_ID', u'6387'),
(u'ID_PART_TABLE_TYPE', u'dos'),
(u'ID_PART_TABLE_UUID', u'5513338d'),
(u'ID_PATH', u'pci-0000:00:1d.0-usb-0:1.2:1.0-scsi-0:0:0:0'),
(u'ID_PATH_TAG', u'pci-0000_00_1d_0-usb-0_1_2_1_0-scsi-0_0_0_0'),
(u'ID_REVISION', u'8.07'),
(u'ID_SERIAL', u'Generic_Flash_Disk_63F2B6EC-0:0'),
(u'ID_SERIAL_SHORT', u'63F2B6EC'),
(u'ID_TYPE', u'disk'),
(u'ID_USB_DRIVER', u'usb-storage'),
(u'ID_USB_INTERFACES', u':080650:'),
(u'ID_USB_INTERFACE_NUM', u'00'),
(u'ID_VENDOR', u'Generic'),
(u'ID_VENDOR_ENC', u'Generic\\x20'),
(u'ID_VENDOR_ID', u'058f'),
(u'MAJOR', u'8'),
(u'MINOR', u'16'),
(u'MPATH_SBIN_PATH', u'/sbin'),
(u'SUBSYSTEM', u'block'),
(u'TAGS', u':systemd:'),
(u'UDISKS_PRESENTATION_NOPOLICY', u'0'),
(u'USEC_INITIALIZED', u'7197321174')]
I want to get some detailed information from the usb subsystem. But how can I find my USB device with the information I retrieved from the block subsystem?
PyUSB would be a good address for detailed USB information indeed. But I use pyudev to monitor the insertion of USB removable devices. So I tried to do all I need with one library.. Here is a code that works but is ugly (as you can see I can extract all information I want using pyudev except the usb size/capacity):
An example output of this script would be: