catching sys.stderr.write error when image is sent and printer is not connected

This commit is contained in:
manetta 2021-03-18 22:39:24 +01:00
parent 73b0f9310f
commit 4069170f3a

View File

@ -9,7 +9,7 @@ import io
def connect():
# Get the printer's USB initializing code with $ sudo lsbusb
try:
lp = printer.Usb(0x4b8,0xe15) # televex printer @ Varia
# lp = printer.Usb(0x4b8,0xe15) # televex printer @ Varia
lp = printer.Usb(0x4b8,0xe03) # printer @ poel
except:
lp = None
@ -113,5 +113,4 @@ def print_now(output, lp=None, type=None):
lp.image(output)
lp.cut()
else:
sys.stderr.write('Printing output to the terminal:\n\n'+output+'\n\n')
sys.stderr.write('Printing output to the terminal:\n\n'+str(output)+'\n\n')