Intégration station d'impression photo (photostation)

- Icône discrète coin bas-gauche, visible seulement si photostation installée
- Popup PIN (4 chiffres) avant lancement
- Backend : /api/photostation/disponible + /api/photostation/lancer
- kiosk-session.sh : Chromium attend le flag /tmp/photostation_running avant redémarrage
- Script install-photostation.sh pour déploiement sur la Surface

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 09:20:48 +02:00
parent fe71921d1a
commit babd89425c
6 changed files with 174 additions and 0 deletions

View File

@@ -774,6 +774,39 @@ async def api_supprimer_animation(nom: str):
return JSONResponse({"erreur": "Fichier introuvable"}, status_code=404)
# --- API Photostation ---
FLAG_PHOTOSTATION = Path("/tmp/photostation_running")
PHOTOSTATION_DIR = Path("/opt/photostation")
@app.get("/api/photostation/disponible")
async def api_photostation_disponible():
disponible = (PHOTOSTATION_DIR / "src" / "main.py").exists()
return {"disponible": disponible}
@app.post("/api/photostation/lancer")
async def api_photostation_lancer():
if not (PHOTOSTATION_DIR / "src" / "main.py").exists():
return JSONResponse({"erreur": "Photostation non installée"}, status_code=404)
asyncio.create_task(_lancer_photostation())
return {"succes": True}
async def _lancer_photostation():
FLAG_PHOTOSTATION.touch()
await asyncio.sleep(1)
# Fermer Chromium (la boucle kiosk attend le flag avant de le relancer)
await asyncio.create_subprocess_exec("pkill", "chromium")
await asyncio.sleep(2)
env = {**__import__("os").environ, "DISPLAY": ":0"}
cmd = f"source {PHOTOSTATION_DIR}/venv/bin/activate && python {PHOTOSTATION_DIR}/src/main.py --kiosk"
proc = await asyncio.create_subprocess_exec("bash", "-c", cmd, env=env)
await proc.wait()
FLAG_PHOTOSTATION.unlink(missing_ok=True)
# --- API Systeme ---
@app.post("/api/systeme/redemarrer")