""" Send one test label to the PT-E560BT. Generates the 63 x 20 mm label and prints it through SumatraPDF with noscale so the QR module pitch reaches the tape unmangled. Reports the real printer exit status rather than assuming success. """ import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) os.chdir(os.path.dirname(os.path.abspath(__file__))) from label_config import load_config, save_config from print_label import print_ptouch_label from ptouch_label import code_density_warning PRINTER = "Brother PT-E560BT" TEST_INVENTORY = sys.argv[1] if len(sys.argv) > 1 else "INV-0001" def main() -> int: cfg = load_config() # Only seed defaults on the very first run so operator settings are kept. if not os.path.exists("label_config.json"): print("No saved settings - writing defaults (edit them in Advanced settings).") cfg.static_lines = ["MOTO ADV SRL", "Articol: CABLU", "Rev: 2026-09"] cfg.qr_prefix = "INV-" save_config(cfg) print(f"Printer : {PRINTER}") print(f"Inventory : {TEST_INVENTORY}") print(f"QR string : {cfg.build_code_payload(TEST_INVENTORY)!r}") print(f"Logo : {cfg.logo_path or '(none set)'}") print(f"Send opts : {cfg.sumatra_settings}") warning = code_density_warning(cfg, TEST_INVENTORY) if warning: print(f"\nWARNING: {warning}") print("\nGenerating and printing...") success, pdf_path, warning = print_ptouch_label(TEST_INVENTORY, PRINTER, cfg) print("\n" + "=" * 62) print(f"PDF : {pdf_path}") print(f"Result : {'SUCCESS' if success else 'FAILED'}") if warning: print(f"Warning : {warning}") print("=" * 62) return 0 if success else 1 if __name__ == "__main__": raise SystemExit(main())