Add support for remote CUPS server

This commit is contained in:
belono 2022-08-28 21:39:01 +02:00
parent 39826c3286
commit f0760ddbc0
1 changed files with 15 additions and 0 deletions

View File

@ -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