Send each print as one job, queue web prints, and harden deploys
Render every print to a complete ESC/POS payload (reset, content, cut)
and send it once over a fresh connection. Only the connect is retried,
so a link that drops mid-job can no longer print a partial image followed
by a full one, and no text size leaks into the next job. Prints are
capped at about 1 m of paper: tall images shrink, over-long notes are
refused.
Replace the argparse/stdout plumbing with PrinterConfig, InvalidJob and
PrinterUnavailable, and one run_command() dispatcher shared by the CLI
and TUI. Status now really connects; before, escpos's lazy open meant
the web server always reported the printer ready. Rendering with the
TM-T20II profile makes QR centering take effect.
The web server validates and renders jobs in the request (400 on bad
input), queues them for a single worker and answers 202; the page
long-polls /api/jobs/{id}, so no request outlives nginx's proxy timeout
while its job still prints. Status reports busy instead of waiting, and
jobs are logged with the nginx user.
update.sh tests new commits in a scratch worktree before touching the
live clone, and rolls back if /healthz doesn't answer after the restart.
The unit runs from the venv, and the web server defaults to localhost.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+3
-3
@@ -126,7 +126,7 @@ class ReceiptApp(App):
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self) -> None:
|
||||
target = "USB" if self.base_args.usb else f"{self.base_args.ip}:{self.base_args.port}"
|
||||
target = receipt.PrinterConfig.from_args(self.base_args).target
|
||||
self.log_panel.write(f"[dim]Printer target: {target}[/dim]")
|
||||
self.refresh_cache_list()
|
||||
|
||||
@@ -199,10 +199,10 @@ class ReceiptApp(App):
|
||||
self.call_from_thread(self.set_buttons_disabled, True)
|
||||
self.call_from_thread(self.log_panel.write, f"[bold]$ {command}[/bold]")
|
||||
try:
|
||||
rc, output = receipt.run_action(command, self.base_args, **params)
|
||||
result = receipt.run_action(command, self.base_args, **params)
|
||||
finally:
|
||||
self.call_from_thread(self.set_buttons_disabled, False)
|
||||
self.call_from_thread(self.report, command, rc, output)
|
||||
self.call_from_thread(self.report, command, result.rc, result.output)
|
||||
|
||||
def report(self, command: str, rc: int, output: str) -> None:
|
||||
if output:
|
||||
|
||||
Reference in New Issue
Block a user