fix: direct-IP fallback when printer_mac unset; force utf-8 in bridge subprocess

Final-review hardening:
- discover_printer falls back to direct IP reachability when printer_mac is
  empty (restores legacy behavior; avoids permanent unreachable on misconfig).
  Keeps the MAC check when a MAC IS set so we never print to a wrong DHCP tenant.
- bridge subprocess decodes child stdout as utf-8 explicitly, so a LANG=C systemd
  locale can't UnicodeDecodeError on the success checkmark and mis-report error.
- add tests for both no-MAC fallback paths (5 passed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mortdecai
2026-06-07 13:48:59 -04:00
parent 03aa1fc7c7
commit b9865be55f
3 changed files with 30 additions and 1 deletions
+2 -1
View File
@@ -69,7 +69,8 @@ def run_briefing(client):
client.publish(STATUS_TOPIC, "printing", retain=True)
log.info("Running briefing...")
r = subprocess.run(["/usr/bin/python3", BRIEFING],
capture_output=True, text=True, timeout=PRINT_TIMEOUT)
capture_output=True, text=True, encoding="utf-8",
timeout=PRINT_TIMEOUT)
if r.returncode == 0 and "Receipt sent" in r.stdout:
client.publish(STATUS_TOPIC, "ok", retain=True)
log.info("Briefing printed OK")