fix: timing flash + couleur idle LED + diagnostic auto-brightness
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled

This commit is contained in:
2026-07-20 19:06:16 +02:00
parent f192ffc92f
commit 19557b20fb
10 changed files with 247 additions and 37 deletions
+22 -8
View File
@@ -168,8 +168,6 @@ async def gallery_print_request(request: Request, body: dict = Body(...)):
"""Demande d'impression depuis la galerie publique.
Vérifie que l'impression est activée et que le quota session n'est pas dépassé.
"""
from pathlib import Path as _Path
cfg_print = request.app.state.config.print
# ── Activation ────────────────────────────────────────────────────────────
@@ -191,15 +189,21 @@ async def gallery_print_request(request: Request, body: dict = Body(...)):
"quota_exceeded": True,
}, status_code=429)
# ── Résolution du fichier ─────────────────────────────────────────────────
media_dir = _Path(request.app.state.config.photobooth.media_dir)
candidates = sorted(media_dir.glob(f"{photo_id}*"))
if not candidates:
# ── Résolution du fichier via l'API photobooth-app ───────────────────────
# On passe par get_media_item() comme le fait admin_print_photo — le champ
# "processed" contient le chemin réel sur le disque (ex: media/processed_full/xxx.jpg).
# Un simple glob sur photo_id ne marche pas car l'id interne ≠ nom de fichier.
pb = request.app.state.photobooth_service
item = await pb.get_media_item(photo_id)
if not item:
return JSONResponse({"error": "Photo introuvable"}, status_code=404)
filepath = str(candidates[0])
file_path = pb.media_file_path(item)
if not file_path or not file_path.exists():
logger.error("Fichier manquant pour %s: %s", photo_id, file_path)
return JSONResponse({"error": "Fichier photo introuvable sur le disque"}, status_code=404)
filepath = str(file_path)
# ── Enqueue ───────────────────────────────────────────────────────────────
pb = request.app.state.photobooth_service
printer_svc = request.app.state.printer_service
ws = request.app.state.ws_manager
led = request.app.state.led_service
@@ -234,6 +238,16 @@ async def gallery_print_request(request: Request, body: dict = Body(...)):
# ── Gestion avancée des imprimantes CUPS ──────────────────────────────────────
@router.post("/print/printers/{printer_name}/set-excluded")
async def set_printer_excluded(request: Request, printer_name: str, excluded: bool = Query(...)):
"""Exclut (ou réintègre) une imprimante du load-balancing JH-Photomaton.
N'agit pas sur CUPS — sert uniquement à ignorer une imprimante temporairement hors ligne."""
config_svc = request.app.state.config_service
config_svc.save_printer_excluded(printer_name, excluded)
logger.info("Imprimante %s : excluded=%s", printer_name, excluded)
return {"ok": True, "printer": printer_name, "excluded": excluded}
@router.post("/print/printers/{printer_name}/enable")
async def printer_enable(request: Request, printer_name: str):
"""Active une imprimante CUPS (cupsenable + cupsaccept)."""