Make windows enablement code more intelligent

This commit is contained in:
Omer Akram 2019-05-22 17:01:13 +05:00
parent 206822ac69
commit d20646b2a9
1 changed files with 5 additions and 4 deletions

View File

@ -17,7 +17,6 @@ import usb.core
import usb.util import usb.util
import serial import serial
import socket import socket
import sys
from .escpos import Escpos from .escpos import Escpos
from .exceptions import USBNotFoundError from .exceptions import USBNotFoundError
@ -69,9 +68,11 @@ class Usb(Escpos):
self.idVendor = self.device.idVendor self.idVendor = self.device.idVendor
self.idProduct = self.device.idProduct self.idProduct = self.device.idProduct
# detach_kernel_driver() doesn't really work on Windows, # pyusb has three backends: libusb0, libusb1 and openusb but
# causing the library to not work on that platform. # only libusb1 backend implements the methods is_kernel_driver_active()
if sys.platform != 'win32': # and detach_kernel_driver(). This change helps enable this
# library to work on Windows.
if sef.device.backend.__module__.endswith("libusb1"):
check_driver = None check_driver = None
try: try: