From 4931a29d45295e3ec57bafa37bb17523d303909a Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 20 Sep 2026 10:59:22 +0200 Subject: [PATCH] Notifier galerie des impressions + luminosite par defaut +15% - notifier_booth_impression() : appelle /gallery/{event}/photo/{name}/imprimee apres chaque impression pour mettre a jour le statut dans la galerie en ligne - Luminosite impression par defaut +15% (corrige photos sombres a l'impression) Co-Authored-By: Claude Opus 4.6 --- backend/destinations.py | 32 ++++++++++++++++++++++++++++++++ backend/printer.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/destinations.py b/backend/destinations.py index 5d37e31..c477f47 100644 --- a/backend/destinations.py +++ b/backend/destinations.py @@ -41,6 +41,14 @@ def distribuer_photo(chemin_photo: Path, imprimee: bool = False, copies: int = 1 if dest.get("ftp", False): envoyer_ftp(chemin_photo, dest, sous_dossier) + # Notifier booth que la photo a ete imprimee + if imprimee and booth.get("actif", False): + threading.Thread( + target=notifier_booth_impression, + args=(chemin_photo.name, copies, booth, config), + daemon=True, + ).start() + # Incrementer le compteur (feuilles 10x15 consommees) if imprimee: compteur = config.get("compteur", {}) @@ -146,6 +154,30 @@ def envoyer_booth(chemin_photo: Path, config_booth: dict): return False +def notifier_booth_impression(filename: str, copies: int, config_booth: dict, config: dict): + """Notifie booth.copydev.fr qu'une photo a ete imprimee.""" + url = config_booth.get("url", "").rstrip("/") + url_tunnel = config_booth.get("url_tunnel", "").rstrip("/") + api_key = config_booth.get("api_key", "") + event_id = config.get("evenement", {}).get("event_id") or config_booth.get("event_id", "default") + + body = json.dumps({"copies": copies}).encode() + for tentative_url in [u for u in (url_tunnel, url) if u]: + try: + req = Request( + f"{tentative_url}/admin/gallery/{event_id}/photo/{filename}/imprimee", + data=body, method="POST", + ) + req.add_header("Content-Type", "application/json") + req.add_header("X-Api-Key", api_key) + with urlopen(req, timeout=10) as resp: + if resp.status == 200: + log.info(f"Booth notifie impression: {filename} x{copies}") + return + except (URLError, OSError) as e: + log.warning(f"Echec notification impression booth: {e}") + + # --- Spool galerie booth --- def _ajouter_booth_spool(chemin: str): diff --git a/backend/printer.py b/backend/printer.py index f76b901..09828fb 100644 --- a/backend/printer.py +++ b/backend/printer.py @@ -111,7 +111,7 @@ def _preparer_image(chemin: Path, largeur: int, hauteur: int, if config_imp.get("rotation_180", False) and not skip_rotate: img = img.rotate(180) - luminosite = config_imp.get("luminosite_impression", 0) + luminosite = config_imp.get("luminosite_impression", 15) if luminosite != 0: from PIL import ImageEnhance facteur = 1.0 + luminosite / 100.0