From b59512490866b54501de4f4290d2c46e9f6e9419 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 10 Sep 2025 14:24:17 -0700 Subject: [PATCH 01/14] virtual printer stuff --- docker-compose.printer.dev.yml | 20 ++++++++++++++++++++ printer/Dockerfile.printer.dev | 23 +++++++++++++++++++++++ printer/server.py | 7 +++++++ printer/what_dev.sh | 9 +++++++++ 4 files changed, 59 insertions(+) create mode 100644 docker-compose.printer.dev.yml create mode 100644 printer/Dockerfile.printer.dev create mode 100644 printer/what_dev.sh diff --git a/docker-compose.printer.dev.yml b/docker-compose.printer.dev.yml new file mode 100644 index 0000000..af422cd --- /dev/null +++ b/docker-compose.printer.dev.yml @@ -0,0 +1,20 @@ +version: '2' +services: + sce-printer: + container_name: sce-printer-dev + build: + context: . + dockerfile: ./printer/Dockerfile.printer.dev + ports: + # we use port 14000 as that is what the website expects + # the printing server to be running on + - 14000:14000 + volumes: + - ./config:/app/config + - ./printer:/app/printer + - ./tmp:/tmp + command: + - --development + - --port=14000 + - --dont-delete-pdfs + - --config-json-path=/app/config/config.json diff --git a/printer/Dockerfile.printer.dev b/printer/Dockerfile.printer.dev new file mode 100644 index 0000000..9510aab --- /dev/null +++ b/printer/Dockerfile.printer.dev @@ -0,0 +1,23 @@ +# Base image from https://github.com/DrPsychick/docker-cups-airprint +# Docker images are here https://hub.docker.com/r/drpsychick/airprint-bridge/tags +FROM drpsychick/airprint-bridge:jammy + +WORKDIR /app + +RUN apt-get update + +RUN apt install -y python3 python3-pip python3-venv + +# Create the virtual environment with Python +RUN python3 -m venv /opt/venv + +# Set the virtual environment as the default Python environment +ENV PATH="/opt/venv/bin:$PATH" + +COPY ./printer/requirements.txt /app/printer/requirements.txt + +RUN /opt/venv/bin/pip install -r /app/printer/requirements.txt + +EXPOSE 9000 + +ENTRYPOINT ["./printer/what_dev.sh"] \ No newline at end of file diff --git a/printer/server.py b/printer/server.py index 27be630..3bab325 100644 --- a/printer/server.py +++ b/printer/server.py @@ -119,6 +119,10 @@ def send_file_to_printer( # only the right printer works right now, so we default to it PRINTER_NAME = os.environ.get("RIGHT_PRINTER_NAME") + + if (args.development): + PRINTER_NAME = "HP_LaserJet_p2015dn_Right" + metrics_handler.print_jobs_recieved.inc() job_id = gerard.create_print_job( @@ -148,6 +152,9 @@ def api(): def metrics(): return prometheus_client.generate_latest() +@app.get("/status/") +async def status(id: str = ''): + return {status: "PRINTED"} @app.post("/print") async def read_item( diff --git a/printer/what_dev.sh b/printer/what_dev.sh new file mode 100644 index 0000000..5834970 --- /dev/null +++ b/printer/what_dev.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +/root/start-cups.sh > /dev/null 2>&1 & + +sleep 10 + +lpadmin -p HP_LaserJet_p2015dn_Right -E -v file:///dev/null + +python3 /app/printer/server.py $@ \ No newline at end of file From d039687eba196c96a20dbe0f7c809e5ffecb3ed4 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Tue, 16 Sep 2025 13:55:45 -0700 Subject: [PATCH 02/14] add dev printer flag; add hold to virtual prints --- docker-compose.printer.dev.yml | 1 + printer/modules/gerard.py | 18 +++++++++++++++--- printer/server.py | 29 +++++++++++++++++++---------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/docker-compose.printer.dev.yml b/docker-compose.printer.dev.yml index af422cd..33bffc6 100644 --- a/docker-compose.printer.dev.yml +++ b/docker-compose.printer.dev.yml @@ -18,3 +18,4 @@ services: - --port=14000 - --dont-delete-pdfs - --config-json-path=/app/config/config.json + - --dev-printer diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index 11c7feb..5198e02 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -5,10 +5,11 @@ import logging import shlex import subprocess - +from datetime import datetime LP_COMMAND = """ lp \ + -H {hold_time} \ -n {num_copies} {maybe_page_range} \ -o sides={sides} \ -o media=na_letter_8.5x11in \ @@ -44,8 +45,19 @@ def create_print_job( printer_name, file_path, is_development_mode=False, + is_dev_printer=False, ): + hold_time = "immediate" + if is_dev_printer: + future_datetime = datetime.fromtimestamp(datetime.utcnow().timestamp() + 60) + # per CUPS docs, -H only accepts HH:MM + # so, rather unfortunately, a virtual print + # will take, at minimum, 1 minute + hold_time = f"{future_datetime.hour}:{future_datetime.minute}" + + command = LP_COMMAND.format( + hold_time=hold_time, num_copies=num_copies, maybe_page_range=maybe_page_range, sides=sides, @@ -53,11 +65,11 @@ def create_print_job( file_path=file_path, ) - if is_development_mode: + if is_development_mode and not is_dev_printer: logging.warning( f"server is in development mode, command would've been `{command}`" ) - job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" + job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" return job_id args_list = shlex.split(command.strip()) diff --git a/printer/server.py b/printer/server.py index 3bab325..39912a3 100644 --- a/printer/server.py +++ b/printer/server.py @@ -63,6 +63,14 @@ def get_args() -> argparse.Namespace: default=False, help="specify if server should run in development. this means requests won't get sent to a printer but logger instead", ) + + parser.add_argument( + "--dev-printer", + action="store_true", + default=False, + help="specify if we should use the virtual dev printer. requests will be processed as if it were a real printer", + ) + parser.add_argument( "--dont-delete-pdfs", action="store_true", @@ -120,13 +128,13 @@ def send_file_to_printer( # only the right printer works right now, so we default to it PRINTER_NAME = os.environ.get("RIGHT_PRINTER_NAME") - if (args.development): + if (args.dev_printer): PRINTER_NAME = "HP_LaserJet_p2015dn_Right" metrics_handler.print_jobs_recieved.inc() job_id = gerard.create_print_job( - num_copies, maybe_page_range, sides, PRINTER_NAME, file_path, args.development + num_copies, maybe_page_range, sides, PRINTER_NAME, file_path, args.development, args.dev_printer ) if job_id: sqlite_helpers.insert_print_job(args.database_file_path, job_id) @@ -154,7 +162,7 @@ def metrics(): @app.get("/status/") async def status(id: str = ''): - return {status: "PRINTED"} + return {"status": "PRINTED"} @app.post("/print") async def read_item( @@ -203,15 +211,16 @@ async def read_item( # metrics_handler referenced by the rest of the file. otherwise, # the thread interacts with an instance different than the one the # server uses -if __name__ == "server" and not args.development: +if __name__ == "server" and (not args.development or args.dev_printer): # set the last time we opened an ssh tunnel to now because # when the script runs for the first time, we did so in what.sh - metrics_handler.ssh_tunnel_last_opened.set(int(time.time())) - t = threading.Thread( - target=maybe_reopen_ssh_tunnel, - daemon=True, - ) - t.start() + if not args.dev_printer: + metrics_handler.ssh_tunnel_last_opened.set(int(time.time())) + t = threading.Thread( + target=maybe_reopen_ssh_tunnel, + daemon=True, + ) + t.start() sqlite_helpers.maybe_create_table(args.database_file_path) From 3a3e7831f4c53c08021d936bd2e24a93c895abb0 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Tue, 16 Sep 2025 22:26:37 -0700 Subject: [PATCH 03/14] LF warning --- printer/what_dev.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/printer/what_dev.sh b/printer/what_dev.sh index 5834970..c14e961 100644 --- a/printer/what_dev.sh +++ b/printer/what_dev.sh @@ -1,5 +1,8 @@ #!/bin/sh +# MAKE SURE THIS FILE IS USING LF FOR ITS EOL SEQUENCE!!!!!!!!!!! +# OTHERWISE DOCKER WILL COMPLAIN THAT THIS FILE DOESNT EXIST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /root/start-cups.sh > /dev/null 2>&1 & sleep 10 From ce21dac5d5656eef74b422c95d19440b4eee7cf2 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 24 Sep 2025 12:51:17 -0700 Subject: [PATCH 04/14] get status from db --- printer/modules/gerard.py | 4 ++-- printer/server.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index 5198e02..3449a02 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -51,8 +51,8 @@ def create_print_job( if is_dev_printer: future_datetime = datetime.fromtimestamp(datetime.utcnow().timestamp() + 60) # per CUPS docs, -H only accepts HH:MM - # so, rather unfortunately, a virtual print - # will take, at minimum, 1 minute + # so a virtual print can take up to a + # minute to complete hold_time = f"{future_datetime.hour}:{future_datetime.minute}" diff --git a/printer/server.py b/printer/server.py index 39912a3..cf42b68 100644 --- a/printer/server.py +++ b/printer/server.py @@ -6,6 +6,7 @@ import threading import time import uuid +import sqlite3 from fastapi import FastAPI, File, Form, HTTPException, UploadFile from fastapi.middleware.cors import CORSMiddleware @@ -162,7 +163,12 @@ def metrics(): @app.get("/status/") async def status(id: str = ''): - return {"status": "PRINTED"} + db = sqlite3.connect(args.database_file_path) + cursor = db.cursor() + cursor.execute(f"SELECT status FROM logs WHERE job_id = ?", (id,)) + status = cursor.fetchone()[0] + + return {"status": status} @app.post("/print") async def read_item( From 1e7e060f13fff350d60d259defd6a2155d07a182 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 24 Sep 2025 12:58:34 -0700 Subject: [PATCH 05/14] just return completed if not using virtual printer and in dev mode --- printer/server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/printer/server.py b/printer/server.py index cf42b68..2ef3b88 100644 --- a/printer/server.py +++ b/printer/server.py @@ -163,6 +163,9 @@ def metrics(): @app.get("/status/") async def status(id: str = ''): + if not args.dev_printer and args.development: + return {"status": "completed"} + db = sqlite3.connect(args.database_file_path) cursor = db.cursor() cursor.execute(f"SELECT status FROM logs WHERE job_id = ?", (id,)) From 16cdf1a569b6cc3c2682243f33141feb1b4b1873 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 24 Sep 2025 13:07:02 -0700 Subject: [PATCH 06/14] i lied --- printer/modules/gerard.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index 3449a02..034185b 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -49,11 +49,8 @@ def create_print_job( ): hold_time = "immediate" if is_dev_printer: - future_datetime = datetime.fromtimestamp(datetime.utcnow().timestamp() + 60) - # per CUPS docs, -H only accepts HH:MM - # so a virtual print can take up to a - # minute to complete - hold_time = f"{future_datetime.hour}:{future_datetime.minute}" + future_datetime = datetime.fromtimestamp(datetime.utcnow().timestamp() + 5) + hold_time = f"{future_datetime.hour}:{future_datetime.minute}:{future_datetime.second}" command = LP_COMMAND.format( From 4db2acd3284ed8ddf97381e790a0693381fe1151 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 24 Sep 2025 13:18:09 -0700 Subject: [PATCH 07/14] fix unit test --- printer/test/test_gerard.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/printer/test/test_gerard.py b/printer/test/test_gerard.py index ddc4ed8..fd10d0f 100644 --- a/printer/test/test_gerard.py +++ b/printer/test/test_gerard.py @@ -41,6 +41,7 @@ def test_create_print_job(self, mock_popen): mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="1", sides="one-side", @@ -76,6 +77,7 @@ def test_create_print_job_nonzero_returncode(self, mock_popen): mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="", sides="dark-side", @@ -113,6 +115,7 @@ def test_create_print_job_cant_parse_stdout(self, mock_popen): mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="1", sides="one-side", From fe13d6cf73a41235b07367433fcb59ffbfe168c7 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Wed, 24 Sep 2025 13:20:38 -0700 Subject: [PATCH 08/14] fix unit tests 2 --- printer/test/test_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/printer/test/test_server.py b/printer/test/test_server.py index 54e278a..56acf3c 100644 --- a/printer/test/test_server.py +++ b/printer/test/test_server.py @@ -78,6 +78,7 @@ def test_print_endpoint(self, mock_pathlib_unlink, mock_open_func, mock_popen, _ mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="", sides="one-sided", @@ -137,6 +138,7 @@ def test_print_endpoint_dont_delete_pdf( mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="", sides="one-sided", @@ -221,6 +223,7 @@ def test_print_endpoint_nonzero_returncode( mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="", sides="dark-side", @@ -275,6 +278,7 @@ def test_junk_print_id(self, mock_pathlib_unlink, mock_open_func, mock_popen, _) mock_popen.call_args_list[0], mock.call( shlex.split(gerard.LP_COMMAND.format( + hold_time="immediate", num_copies=1, maybe_page_range="", sides="one-sided", From 2d1acc20ebf27dd0d345330e4d56976219ff1bc2 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Tue, 7 Oct 2025 13:30:42 -0700 Subject: [PATCH 09/14] error checking for status; some other misc changes --- printer/modules/gerard.py | 4 ++-- printer/server.py | 15 +++++++++------ printer/what_dev.sh | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index 034185b..b8a703c 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -5,7 +5,7 @@ import logging import shlex import subprocess -from datetime import datetime +import datetime LP_COMMAND = """ lp \ @@ -66,7 +66,7 @@ def create_print_job( logging.warning( f"server is in development mode, command would've been `{command}`" ) - job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" + job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" return job_id args_list = shlex.split(command.strip()) diff --git a/printer/server.py b/printer/server.py index 2ef3b88..4ddf8c9 100644 --- a/printer/server.py +++ b/printer/server.py @@ -166,12 +166,15 @@ async def status(id: str = ''): if not args.dev_printer and args.development: return {"status": "completed"} - db = sqlite3.connect(args.database_file_path) - cursor = db.cursor() - cursor.execute(f"SELECT status FROM logs WHERE job_id = ?", (id,)) - status = cursor.fetchone()[0] - - return {"status": status} + try: + db = sqlite3.connect(args.database_file_path) + cursor = db.cursor() + cursor.execute(f"SELECT status FROM logs WHERE job_id = ?", (id,)) + status = cursor.fetchone()[0] + return {"status": status} + except Exception: + logging.exception("failed to get status of job with id: " + id) + return {"status": "failed"} @app.post("/print") async def read_item( diff --git a/printer/what_dev.sh b/printer/what_dev.sh index c14e961..4b0b4d4 100644 --- a/printer/what_dev.sh +++ b/printer/what_dev.sh @@ -9,4 +9,4 @@ sleep 10 lpadmin -p HP_LaserJet_p2015dn_Right -E -v file:///dev/null -python3 /app/printer/server.py $@ \ No newline at end of file +python3 /app/printer/server.py $@ From 7761b97370f46d7e837b7016a5a9ec301bad2f55 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Tue, 14 Oct 2025 14:16:14 -0700 Subject: [PATCH 10/14] fix bad datetime module access --- printer/modules/gerard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index b8a703c..fb02f22 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -49,7 +49,7 @@ def create_print_job( ): hold_time = "immediate" if is_dev_printer: - future_datetime = datetime.fromtimestamp(datetime.utcnow().timestamp() + 5) + future_datetime = datetime.datetime.fromtimestamp(datetime.datetime.utcnow().timestamp() + 5) hold_time = f"{future_datetime.hour}:{future_datetime.minute}:{future_datetime.second}" From 7092d612de8ff8886fa305a3e32b233569aef138 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Mon, 22 Dec 2025 12:38:03 -0800 Subject: [PATCH 11/14] remove dev printer flag --- docker-compose.printer.dev.yml | 1 - printer/modules/gerard.py | 3 +-- printer/server.py | 29 +++++++++-------------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/docker-compose.printer.dev.yml b/docker-compose.printer.dev.yml index 33bffc6..af422cd 100644 --- a/docker-compose.printer.dev.yml +++ b/docker-compose.printer.dev.yml @@ -18,4 +18,3 @@ services: - --port=14000 - --dont-delete-pdfs - --config-json-path=/app/config/config.json - - --dev-printer diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index fb02f22..b60ff81 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -45,10 +45,9 @@ def create_print_job( printer_name, file_path, is_development_mode=False, - is_dev_printer=False, ): hold_time = "immediate" - if is_dev_printer: + if is_development_mode: future_datetime = datetime.datetime.fromtimestamp(datetime.datetime.utcnow().timestamp() + 5) hold_time = f"{future_datetime.hour}:{future_datetime.minute}:{future_datetime.second}" diff --git a/printer/server.py b/printer/server.py index 4ddf8c9..2ccf10a 100644 --- a/printer/server.py +++ b/printer/server.py @@ -65,13 +65,6 @@ def get_args() -> argparse.Namespace: help="specify if server should run in development. this means requests won't get sent to a printer but logger instead", ) - parser.add_argument( - "--dev-printer", - action="store_true", - default=False, - help="specify if we should use the virtual dev printer. requests will be processed as if it were a real printer", - ) - parser.add_argument( "--dont-delete-pdfs", action="store_true", @@ -129,13 +122,13 @@ def send_file_to_printer( # only the right printer works right now, so we default to it PRINTER_NAME = os.environ.get("RIGHT_PRINTER_NAME") - if (args.dev_printer): + if (args.development): PRINTER_NAME = "HP_LaserJet_p2015dn_Right" metrics_handler.print_jobs_recieved.inc() job_id = gerard.create_print_job( - num_copies, maybe_page_range, sides, PRINTER_NAME, file_path, args.development, args.dev_printer + num_copies, maybe_page_range, sides, PRINTER_NAME, file_path, args.development ) if job_id: sqlite_helpers.insert_print_job(args.database_file_path, job_id) @@ -163,9 +156,6 @@ def metrics(): @app.get("/status/") async def status(id: str = ''): - if not args.dev_printer and args.development: - return {"status": "completed"} - try: db = sqlite3.connect(args.database_file_path) cursor = db.cursor() @@ -223,16 +213,15 @@ async def read_item( # metrics_handler referenced by the rest of the file. otherwise, # the thread interacts with an instance different than the one the # server uses -if __name__ == "server" and (not args.development or args.dev_printer): +if __name__ == "server" and not args.development: # set the last time we opened an ssh tunnel to now because # when the script runs for the first time, we did so in what.sh - if not args.dev_printer: - metrics_handler.ssh_tunnel_last_opened.set(int(time.time())) - t = threading.Thread( - target=maybe_reopen_ssh_tunnel, - daemon=True, - ) - t.start() + metrics_handler.ssh_tunnel_last_opened.set(int(time.time())) + t = threading.Thread( + target=maybe_reopen_ssh_tunnel, + daemon=True, + ) + t.start() sqlite_helpers.maybe_create_table(args.database_file_path) From 47389cd6ae6dda2a7bcca7bbde158e3f5bf82022 Mon Sep 17 00:00:00 2001 From: thebeninator Date: Mon, 22 Dec 2025 12:40:23 -0800 Subject: [PATCH 12/14] remove dev printer flag again --- printer/modules/gerard.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index b60ff81..d075318 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -61,13 +61,6 @@ def create_print_job( file_path=file_path, ) - if is_development_mode and not is_dev_printer: - logging.warning( - f"server is in development mode, command would've been `{command}`" - ) - job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" - return job_id - args_list = shlex.split(command.strip()) logging.info(f"running command {command}") print_job = subprocess.Popen( From 65023cf7e17b5361e484894237bc0cf682c5cf5c Mon Sep 17 00:00:00 2001 From: thebeninator Date: Mon, 22 Dec 2025 12:48:22 -0800 Subject: [PATCH 13/14] fix tests --- printer/modules/gerard.py | 10 +++++++++- printer/test/test_gerard.py | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index d075318..f0312ff 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -37,7 +37,6 @@ def __next__(self): print_job_suffix = IDIterator() - def create_print_job( num_copies, maybe_page_range, @@ -45,6 +44,7 @@ def create_print_job( printer_name, file_path, is_development_mode=False, + no_dev_printer=False ): hold_time = "immediate" if is_development_mode: @@ -61,6 +61,14 @@ def create_print_job( file_path=file_path, ) + if no_dev_printer: + logging.warning( + f"server is in development mode, command would've been `{command}`" + ) + job_id = f"HP_LaserJet_p2015dn_Right-{next(print_job_suffix)}" + return job_id + + args_list = shlex.split(command.strip()) logging.info(f"running command {command}") print_job = subprocess.Popen( diff --git a/printer/test/test_gerard.py b/printer/test/test_gerard.py index fd10d0f..7d6b831 100644 --- a/printer/test/test_gerard.py +++ b/printer/test/test_gerard.py @@ -132,19 +132,19 @@ def test_create_print_job_cant_parse_development_mode(self): self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True ), "HP_LaserJet_p2015dn_Right-0", ) self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True ), "HP_LaserJet_p2015dn_Right-1", ) self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True ), "HP_LaserJet_p2015dn_Right-2", ) From 9a9a331491ee7012d4db7d6c6608445e86486a6b Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 22 Dec 2025 12:54:04 -0800 Subject: [PATCH 14/14] is_development_mode --- printer/modules/gerard.py | 4 ++-- printer/test/test_gerard.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/printer/modules/gerard.py b/printer/modules/gerard.py index f0312ff..cde3d46 100644 --- a/printer/modules/gerard.py +++ b/printer/modules/gerard.py @@ -44,7 +44,7 @@ def create_print_job( printer_name, file_path, is_development_mode=False, - no_dev_printer=False + # no_dev_printer=False ): hold_time = "immediate" if is_development_mode: @@ -61,7 +61,7 @@ def create_print_job( file_path=file_path, ) - if no_dev_printer: + if is_development_mode: logging.warning( f"server is in development mode, command would've been `{command}`" ) diff --git a/printer/test/test_gerard.py b/printer/test/test_gerard.py index 7d6b831..08e8053 100644 --- a/printer/test/test_gerard.py +++ b/printer/test/test_gerard.py @@ -132,19 +132,19 @@ def test_create_print_job_cant_parse_development_mode(self): self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, ), "HP_LaserJet_p2015dn_Right-0", ) self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, ), "HP_LaserJet_p2015dn_Right-1", ) self.assertEqual( gerard.create_print_job( - 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, True + 1, "1", "one-side", "HP_P2015_DN", "/tmp/test-id", True, ), "HP_LaserJet_p2015dn_Right-2", )