From f0760ddbc0c75cf8d07baf8e58b51949e9ecf32e Mon Sep 17 00:00:00 2001 From: belono Date: Sun, 28 Aug 2022 21:39:01 +0200 Subject: [PATCH] Add support for remote CUPS server --- src/escpos/printer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/escpos/printer.py b/src/escpos/printer.py index c3666c3..91cc07f 100644 --- a/src/escpos/printer.py +++ b/src/escpos/printer.py @@ -404,7 +404,22 @@ if _CUPSPRINT: """ Simple CUPS printer connector. """ def __init__(self, printer_name=None, *args, **kwargs): + """CupsPrinter constructor. + + :param printer_name: CUPS printer name (Optional) + :type printer_name: str + :param host: CUPS server host/ip (Optional) + :type host: str + :param port: CUPS server port (Optional) + :type port: int + """ Escpos.__init__(self, *args, **kwargs) + host, port = args or ( + kwargs.get('host', cups.getServer()), + kwargs.get('port', cups.getPort()) + ) + cups.setServer(host) + cups.setPort(port) self.conn = cups.Connection() self.tmpfile = None self.printer_name = printer_name