diff --git a/.gitignore b/.gitignore index 9c802d7..c871d27 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,5 @@ __pycache__/ result* -.env - scratch.py test.py diff --git a/printer.py b/printer.py index 8e377f1..bbae47c 100644 --- a/printer.py +++ b/printer.py @@ -1,20 +1,5 @@ -import logging -import os -from itertools import zip_longest - -from dotenv import find_dotenv, load_dotenv from escpos.printer import CupsPrinter - -log = logging.getLogger("receipt-printer") -log.setLevel(logging.WARNING) - -if load_dotenv(find_dotenv(usecwd=True)): - log.debug("Loaded .env") -else: - log.debug("Didn't find .env") - - -RECEIPT_PRINTER = os.getenv("RECEIPT_PRINTER") +from itertools import zip_longest class CallbackContext: @@ -87,7 +72,7 @@ class ReceiptPrinter(CupsPrinter): return CallbackContext(exit=super().set_with_default) def split(self, left, right, cols=48): - self.textln(f"{left:<{cols // 2}}{right:<{cols // 2}}") + self.textln(f"{left:<{cols//2}}{right:<{cols//2}}") def vsplit(self, *args, **kwargs): return Split2Context(self, *args, **kwargs) @@ -111,15 +96,7 @@ class ReceiptPrinter(CupsPrinter): def title(self, text, size=6, width=None, height=None): width = width or size height = height or size - with self.set( - align="center", - bold=True, - invert=True, - smooth=True, - custom_size=True, - width=width, - height=height, - ): + with self.set(align="center", bold=True, invert=True, smooth=True, custom_size=True, width=width, height=height): self.textln(text) self.ln() @@ -127,5 +104,5 @@ class ReceiptPrinter(CupsPrinter): with self.set(align="center", double_height=True, double_width=True): p.textln(text) - -p = ReceiptPrinter(RECEIPT_PRINTER, profile="default") +#p = ReceiptPrinter("EPSON-TM-m30", profile="default") +p = ReceiptPrinter("EPSON-TM-m30-remote", profile="default")