[IMP] hw_escpos: more fault tolerant printer detection
In some cases, the description fails (unknow printer, udev issues,...) and while the printer works fine, the description fails.
This commit is contained in:
@@ -77,10 +77,15 @@ class EscposDriver(Thread):
|
||||
printers = usb.core.find(find_all=True, idVendor=0x0519)
|
||||
|
||||
for printer in printers:
|
||||
try:
|
||||
description = usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct)
|
||||
except Exception as e:
|
||||
_logger.error("Can not get printer description: %s" % (e.message or repr(e)))
|
||||
description = 'Unknown printer'
|
||||
connected.append({
|
||||
'vendor': printer.idVendor,
|
||||
'product': printer.idProduct,
|
||||
'name': usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct)
|
||||
'name': description
|
||||
})
|
||||
|
||||
return connected
|
||||
|
||||
Reference in New Issue
Block a user