Ajout d'un try/except

This commit is contained in:
n07070 2022-03-15 14:49:26 +01:00
parent be3770956c
commit 4fea7c1e86

View File

@ -120,13 +120,17 @@ class Printer(object):
return False return False
if not os.getenv('LIPY_DEBUG') == True: if not os.getenv('LIPY_DEBUG') == True:
try:
self.printer.open(self.usb_args); self.printer.open(self.usb_args);
self.printer.set(align='left', font='a', bold=False, underline=0, width=1, height=1, density=8, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False) self.printer.set(align='left', font='a', bold=False, underline=0, width=1, height=1, density=8, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
self.printer.textln(clean_msg) self.printer.textln(clean_msg)
self.printer.set(align='left', font='b', bold=False, underline=1, width=1, height=1, density=9, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False) self.printer.set(align='left', font='b', bold=False, underline=1, width=1, height=1, density=9, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime()))
self.printer.cut() self.printer.cut()
self.printer.close() self.printer.close
except Exception as e:
flash("Unable to print because : " + e)
flash("Message printed : " + clean_msg ,category='info') flash("Message printed : " + clean_msg ,category='info')
return True return True