From 4fea7c1e863489525a4a7f87fc8844aa85e1b41c Mon Sep 17 00:00:00 2001 From: n07070 Date: Tue, 15 Mar 2022 14:49:26 +0100 Subject: [PATCH] Ajout d'un try/except --- src/printer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/printer.py b/src/printer.py index dfd8075..9f2ea07 100644 --- a/src/printer.py +++ b/src/printer.py @@ -120,13 +120,17 @@ class Printer(object): return False if not os.getenv('LIPY_DEBUG') == True: - 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.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.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) - self.printer.cut() - self.printer.close() + try: + 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.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.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) + self.printer.cut() + self.printer.close + except Exception as e: + flash("Unable to print because : " + e) + flash("Message printed : " + clean_msg ,category='info') return True