Changes to be committed:
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled

modified:   Opencode/scripts/script_print.sh
	modified:   backend/services/printer_service.py
	modified:   frontend/templates/admin/actions.html
	modified:   frontend/templates/admin/events.html
	modified:   frontend/templates/admin/gallery.html
	modified:   frontend/templates/admin/settings.html
	modified:   frontend/templates/base.html
	modified:   frontend/templates/public/gallery.html
 Untracked files:
	photobooth-app/script/
	photobooth-app/userdata/
This commit is contained in:
2026-07-17 17:02:57 +02:00
parent c32b3ba345
commit 68b0a36031
8 changed files with 92 additions and 68 deletions
+17 -8
View File
@@ -235,17 +235,26 @@ class PrinterService:
cmd = ["/bin/bash", script, filename, "image", "default", str(copies)]
try:
proc = subprocess.run(
cmd, capture_output=True, text=True, timeout=60
cmd, capture_output=True, text=True, timeout=120
)
stdout = proc.stdout.strip()
if proc.returncode == 0 and "PRINTED:" in stdout:
parts = stdout.split(":")
printer = parts[1] if len(parts) > 1 else ""
return {"success": True, "printer": printer, "output": stdout}
else:
return {"success": False, "error": proc.stderr.strip() or stdout, "printer": ""}
# Cherche PRINTED: ou PRINT_ERROR: dans la dernière ligne significative
for line in reversed(stdout.splitlines()):
line = line.strip()
if line.startswith("PRINTED:"):
parts = line.split(":")
printer = parts[1] if len(parts) > 1 else ""
return {"success": True, "printer": printer, "output": stdout}
if line.startswith("PRINT_ERROR:"):
parts = line.split(":", 2)
printer = parts[1] if len(parts) > 1 else ""
reason = parts[2] if len(parts) > 2 else ""
err_msg = f"Erreur imprimante {printer}: {reason}" if reason else f"Erreur imprimante {printer}"
return {"success": False, "error": err_msg, "printer": printer}
# Aucun marqueur reconnu
return {"success": False, "error": proc.stderr.strip() or stdout or "Script sans sortie reconnue", "printer": ""}
except subprocess.TimeoutExpired:
return {"success": False, "error": "Timeout impression (60s)"}
return {"success": False, "error": "Timeout impression (120s)"}
except Exception as e:
return {"success": False, "error": str(e)}