不仅可以尝试lsusb,还可以尝试dbus。
以下是一个python代码示例,它列出了硬件层次结构中的所有scsi_host父级。
导入数据库
bus=dbus.SystemBus ()
u'/org/freedesktop/Hal/Manager ' )
volume _ udi _ list=Hal _ manager.finddevicebycapability (SCSI _ host ) )。
for udi in volume_udi_list:
# inspect all scsi_host devices
volume=dbus.interface(dev,u'org.freedesktop.Hal.Device ) ) ) ) ) ) ) )。
# get their parent
parent=volume.getproperty (' info.parent ' ) )。
volume=dbus.interface(dev,u'org.freedesktop.Hal.Device ) ) ) ) ) ) ) )。
# herewecanfindvendoridforusb- storage devices
props=volume.GetAllProperties (
print'n'.join((%s:%s'% ) k,props[k] ) for k in props )