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