usbinfo/linux.py
def usbinfo():
    """
    Helper for usbinfo on Linux.
    """

    info_list = []

    _mounts = get_mounts()

    context = pyudev.Context()
    devices = context.list_devices().match_property('ID_BUS', 'usb')

    device_it = devices.__iter__()

    while True:
        try:
            # We need to manually get the next item in the iterator because
            # pyudev.device may throw an exception
            device = next(device_it)
        except pyudev.device.DeviceNotFoundError:
            continue
        except StopIteration:
            break

        devinfo = {
            'bInterfaceNumber': device.get('ID_USB_INTERFACE_NUM', u''),
            'iManufacturer': device.get('ID_VENDOR', u''),
            'idVendor': device.get('ID_VENDOR_ID', u''),
            'iProduct': device.get('ID_MODEL', u''),
            'idProduct': device.get('ID_MODEL_ID', u''),
            'iSerialNumber': device.get('ID_SERIAL_SHORT', u''),
            'devname': device.get('DEVNAME', u''),
        }

        mount = _mounts.get(device.get('DEVNAME'))
        if mount:
            devinfo['mount'] = mount

        info_list.append(devinfo)

    return info_list

    Helper for usbinfo on Linux.
    
Helper for usbinfo on Linux.
Helper for usbinfo on Linux .
def usbinfo():
    info_list = []
    _mounts = get_mounts()
    context = pyudev.Context()
    devices = context.list_devices().match_property('ID_BUS', 'usb')
    device_it = devices.__iter__()
    while True:
        try:
            device = next(device_it)
        except pyudev.device.DeviceNotFoundError:
            continue
        except StopIteration:
            break
        devinfo = {
            'bInterfaceNumber': device.get('ID_USB_INTERFACE_NUM', u''),
            'iManufacturer': device.get('ID_VENDOR', u''),
            'idVendor': device.get('ID_VENDOR_ID', u''),
            'iProduct': device.get('ID_MODEL', u''),
            'idProduct': device.get('ID_MODEL_ID', u''),
            'iSerialNumber': device.get('ID_SERIAL_SHORT', u''),
            'devname': device.get('DEVNAME', u''),
        }
        mount = _mounts.get(device.get('DEVNAME'))
        if mount:
            devinfo['mount'] = mount
        info_list.append(devinfo)
    return info_list
def usbinfo ( ) : info_list = [ ] _mounts = get_mounts ( ) context = pyudev . Context ( ) devices = context . list_devices ( ) . match_property ( 'ID_BUS' , 'usb' ) device_it = devices . __iter__ ( ) while True : try : device = next ( device_it ) except pyudev . device . DeviceNotFoundError : continue except StopIteration : break devinfo = { 'bInterfaceNumber' : device . get ( 'ID_USB_INTERFACE_NUM' , u'' ) , 'iManufacturer' : device . get ( 'ID_VENDOR' , u'' ) , 'idVendor' : device . get ( 'ID_VENDOR_ID' , u'' ) , 'iProduct' : device . get ( 'ID_MODEL' , u'' ) , 'idProduct' : device . get ( 'ID_MODEL_ID' , u'' ) , 'iSerialNumber' : device . get ( 'ID_SERIAL_SHORT' , u'' ) , 'devname' : device . get ( 'DEVNAME' , u'' ) , } mount = _mounts . get ( device . get ( 'DEVNAME' ) ) if mount : devinfo [ 'mount' ] = mount info_list . append ( devinfo ) return info_list
Helper for usbinfo on Linux.
Helper for usbinfo on Linux .
"""
    Helper for usbinfo on Linux.
    """ # We need to manually get the next item in the iterator because # pyudev.device may throw an exception