diff --git a/src/printer.py b/src/printer.py index 5099345..e5ac00a 100644 --- a/src/printer.py +++ b/src/printer.py @@ -31,13 +31,16 @@ class Printer(object): self.printer = None def init_printer(self, device_id,vendor_id): + try: - p = Usb(vendor_id, device_id) + p = Usb(0x04b8, 0x0e28, 0) except USBNotFoundError as e: - self.app.logger.error("The USB device is not plugged in, aborting...") - exit(-1) + self.app.logger.error("The USB device is not plugged in, aborting..." + str(e)) + return False waiting_elapsed = 10 + # p.open() + # Is the printer online ? Is the communication with the printer successfull ? while not p.is_online(): self.app.logger.debug('Waiting for printer to get online...') @@ -59,12 +62,12 @@ class Printer(object): self.app.logger.debug('Printer has paper, good to go') # We're going to print a little text to let know that we're good, as a final check. - p.textln("Hello world ! \nStarting up at " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) - p.set(align='center', font='a', bold=False, underline=0, width=1, height=1, density=9, invert=False, smooth=False, flip=False, double_width=False, double_height=False, custom_size=False) - p.textln("------------------") - p.qr("Hello World ! :)") - p.image("../configuration/hello_world.png",center=True) - p.cut() + # p.textln("Hello world ! \nStarting up at " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) + # p.set(align='center', font='a', bold=False, underline=0, width=1, height=1, density=9, invert=False, smooth=False, flip=False, double_width=False, double_height=False, custom_size=False) + # p.textln("------------------") + # p.qr("Hello World ! :)",size=1) + p.image("configuration/hello_world.png",center=True,impl='bitImageColumn') + # p.cut() self.printer = p; self.ready = True;