- Intégration selphy_print (backend CUPS dyesub Mitsubishi CP-K60DW-S) - Formats impression : 15x20, 10x15, 10x15 2-strips avec cadre et orientation portrait/paysage - Cadres d'impression par format (strip/10x15/15x20) : upload, sélection, aperçu live - Cadres démo générés : pellicule noir/vintage/couleurs + bordures classique/doré/rose gold - Écran de choix de cadre avant capture (clic direct, aperçu grand format) - Filtres réduits à 3 (Couleur, N&B, Sépia) et appliqués sur tous les strips - Port 80 via authbind, route /admin avec redirection auto depuis poste distant - Autologin LightDM corrigé (pam-autologin-service) - Bouton évacuer bourrage papier dans admin - Fix : _gp_lock manquant dans Camera.__init__ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
import json
|
|
import os
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
RACINE = Path(__file__).resolve().parent.parent
|
|
CHEMIN_CONFIG = RACINE / "data" / "config.json"
|
|
CHEMIN_CONFIG_DEFAUT = RACINE / "data" / "config.defaut.json"
|
|
DOSSIER_PHOTOS = RACINE / "data" / "photos"
|
|
DOSSIER_EXPORTS = RACINE / "data" / "exports"
|
|
DOSSIER_OVERLAYS = RACINE / "frontend" / "assets" / "overlays"
|
|
DOSSIER_FONDS = RACINE / "frontend" / "assets" / "backgrounds"
|
|
DOSSIER_ANIMATIONS = RACINE / "frontend" / "assets" / "animations"
|
|
DOSSIER_CADRES = RACINE / "frontend" / "assets" / "cadres"
|
|
FORMATS_CADRES = ["strip", "10x15", "15x20"]
|
|
|
|
|
|
def charger_config() -> dict:
|
|
"""Charge la configuration depuis config.json."""
|
|
if not CHEMIN_CONFIG.exists():
|
|
if CHEMIN_CONFIG_DEFAUT.exists():
|
|
shutil.copy(CHEMIN_CONFIG_DEFAUT, CHEMIN_CONFIG)
|
|
else:
|
|
return {}
|
|
with open(CHEMIN_CONFIG, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
def sauvegarder_config(config: dict):
|
|
"""Sauvegarde la configuration dans config.json."""
|
|
CHEMIN_CONFIG.parent.mkdir(parents=True, exist_ok=True)
|
|
with open(CHEMIN_CONFIG, "w", encoding="utf-8") as f:
|
|
json.dump(config, f, ensure_ascii=False, indent=2)
|
|
|
|
|
|
def mettre_a_jour_config(modifications: dict) -> dict:
|
|
"""Met a jour la configuration avec les modifications fournies (merge profond)."""
|
|
config = charger_config()
|
|
_merge_profond(config, modifications)
|
|
sauvegarder_config(config)
|
|
return config
|
|
|
|
|
|
def _merge_profond(base: dict, modifications: dict):
|
|
"""Fusionne recursivement les modifications dans la base."""
|
|
for cle, valeur in modifications.items():
|
|
if cle in base and isinstance(base[cle], dict) and isinstance(valeur, dict):
|
|
_merge_profond(base[cle], valeur)
|
|
else:
|
|
base[cle] = valeur
|
|
|
|
|
|
# Initialisation des dossiers au chargement du module
|
|
for dossier in [DOSSIER_PHOTOS, DOSSIER_EXPORTS, DOSSIER_OVERLAYS, DOSSIER_FONDS, DOSSIER_ANIMATIONS]:
|
|
dossier.mkdir(parents=True, exist_ok=True)
|
|
for fmt in FORMATS_CADRES:
|
|
(DOSSIER_CADRES / fmt).mkdir(parents=True, exist_ok=True)
|