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 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,14 @@ def distribuer_photo(chemin_photo: Path, imprimee: bool = False, copies: int = 1
|
|||||||
if dest.get("ftp", False):
|
if dest.get("ftp", False):
|
||||||
envoyer_ftp(chemin_photo, dest, sous_dossier)
|
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)
|
# Incrementer le compteur (feuilles 10x15 consommees)
|
||||||
if imprimee:
|
if imprimee:
|
||||||
compteur = config.get("compteur", {})
|
compteur = config.get("compteur", {})
|
||||||
@@ -146,6 +154,30 @@ def envoyer_booth(chemin_photo: Path, config_booth: dict):
|
|||||||
return False
|
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 ---
|
# --- Spool galerie booth ---
|
||||||
|
|
||||||
def _ajouter_booth_spool(chemin: str):
|
def _ajouter_booth_spool(chemin: str):
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ def _preparer_image(chemin: Path, largeur: int, hauteur: int,
|
|||||||
if config_imp.get("rotation_180", False) and not skip_rotate:
|
if config_imp.get("rotation_180", False) and not skip_rotate:
|
||||||
img = img.rotate(180)
|
img = img.rotate(180)
|
||||||
|
|
||||||
luminosite = config_imp.get("luminosite_impression", 0)
|
luminosite = config_imp.get("luminosite_impression", 15)
|
||||||
if luminosite != 0:
|
if luminosite != 0:
|
||||||
from PIL import ImageEnhance
|
from PIL import ImageEnhance
|
||||||
facteur = 1.0 + luminosite / 100.0
|
facteur = 1.0 + luminosite / 100.0
|
||||||
|
|||||||
Reference in New Issue
Block a user