1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-12-02 09:43:30 +00:00

Merge remote-tracking branch 'faulab/fix-pc1252'

This commit is contained in:
Christoph Heuel
2015-12-12 16:43:27 +01:00
6 changed files with 25 additions and 67 deletions

View File

@@ -41,11 +41,19 @@ class Usb(Escpos):
if self.device is None:
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:
self.device.detach_kernel_driver(0)
except usb.core.USBError as e:
print("Could not detatch kernel driver: %s" % str(e))
if check_driver is not None:
print("Could not detatch kernel driver: %s" % str(e))
try:
self.device.set_configuration()