Merge pull request #61 from HarkonenBade/support-for-libusb0
Prevent crash when using libusb0 printers
This commit is contained in:
commit
ef84a5150f
|
@ -40,10 +40,18 @@ class Usb(Escpos):
|
||||||
if self.device is None:
|
if self.device is None:
|
||||||
print "Cable isn't plugged in"
|
print "Cable isn't plugged in"
|
||||||
|
|
||||||
if self.device.is_kernel_driver_active(0):
|
check_driver = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
check_driver = self.device.is_kernel_driver_active(0)
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if check_driver is None or check_driver:
|
||||||
try:
|
try:
|
||||||
self.device.detach_kernel_driver(0)
|
self.device.detach_kernel_driver(0)
|
||||||
except usb.core.USBError as e:
|
except usb.core.USBError as e:
|
||||||
|
if check_driver is not None:
|
||||||
print "Could not detatch kernel driver: %s" % str(e)
|
print "Could not detatch kernel driver: %s" % str(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue