Eric-Canas / USBMonitor

USBMonitor is an easy-to-use cross-platform library for USB device monitoring that simplifies tracking of connections, disconnections, and examination of connected device attributes on both Windows and Linux, freeing the user from platform-specific details or incompatibilities.
MIT License
33 stars 7 forks source link

Create support for USBPRINT driver type or at least allow to ignore it #6

Open jokubas11 opened 3 months ago

jokubas11 commented 3 months ago

I have a USB printer connected and I cannot initialize the USBMonitor class, even if I device to use filter_devices argument, which would exclude that particular printer, so theoretically I am unable to even use this package whenever the printer is connected to PC, unless I modify source code in the package to ignore any USBPRINT devices.

  File "C:\projects\label_printer\env\lib\site-packages\usbmonitor\__platform_specific_detectors\_windows_usb_detector.py", line 126, in __get_driver_type_from_device_id
    assert driver_type in _WINDOWS_REGEX_ATTRIBUTES_BY_DRIVER, f"The driver type '{driver_type}' is not supported " \
AssertionError: The driver type 'USBPRINT' is not supported yet, please create an issue in github
daringer commented 2 weeks ago

@Eric-Canas would you mind taking a look at how this might be implemented, I'd like to help - but it's not entirely clear to me how to solve that - I also don't have devices to test this - essentially a first fix might be just skipping such devices, or do you have a better suggestion how to avoid crashing usbmonitor if such a device is connected?