cb7ad8b0ff
Replaces the never-installed cron approach with an MQTT bridge mirroring the lgtv pattern: Google Home button -> HA script/scene -> MQTT -> steel141 prints. Adds MAC-based printer discovery (printer IP is DHCP-unstable) and a gemma4 summarizer swap. Includes scripts/dryrun.py (non-printing pipeline harness). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Dry-run harness: exercises the full pos_briefing pipeline WITHOUT printing.
|
|
|
|
Monkeypatches print_receipt so nothing is sent to the TM-m30 over TCP. Reports
|
|
which data sources succeeded/failed and the receipt byte length. Use to verify
|
|
the script runs end-to-end on a host before scheduling it via cron.
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
import pos_briefing as pb
|
|
|
|
|
|
def fake_print_receipt(raw):
|
|
print(f"[dry-run] print_receipt() suppressed — {len(raw)} bytes would be sent "
|
|
f"to {pb.PRINTER_IP}:{pb.PRINTER_PORT}")
|
|
return True
|
|
|
|
|
|
pb.print_receipt = fake_print_receipt
|
|
|
|
|
|
def probe(name, fn):
|
|
try:
|
|
v = fn()
|
|
ok = v is not None and v != [] and v != {}
|
|
print(f" {'OK ' if ok else 'NIL'} {name}: {repr(v)[:120]}")
|
|
return v
|
|
except Exception as e:
|
|
print(f" ERR {name}: {type(e).__name__}: {e}")
|
|
return None
|
|
|
|
|
|
print("=== data source probes ===")
|
|
items, token = (pb.fetch_news() if True else (None, None))
|
|
print(f" news: {len(items) if items else 0} items, token={'yes' if token else 'no'}")
|
|
zfs = probe("zfs", pb.get_zfs_status)
|
|
reddit = probe("reddit", pb.get_reddit_top)
|
|
grafana = probe("grafana", pb.get_grafana_metrics)
|
|
weather = probe("weather", pb.get_weather)
|
|
finance = probe("finance", pb.get_financial_snapshot)
|
|
|
|
print("=== build + (suppressed) print ===")
|
|
articles = pb.summarize_news(items, count=5, length="30-50 words") if items else []
|
|
print(f" articles summarized: {len(articles)}")
|
|
raw = pb.build_receipt(articles, zfs, reddit, grafana, weather, finance)
|
|
pb.print_receipt(raw)
|
|
print("=== done (nothing printed) ===")
|