fix: timing flash + couleur idle LED + diagnostic auto-brightness
This commit is contained in:
@@ -244,7 +244,13 @@ class PrinterService:
|
||||
if not Path(filename).exists():
|
||||
return {"success": False, "error": f"Fichier introuvable: {filename}"}
|
||||
|
||||
cmd = ["/bin/bash", script, filename, "image", "default", str(copies)]
|
||||
# Imprimantes exclues du load-balancing (flag excluded dans config)
|
||||
excluded_list = ",".join(
|
||||
self._printer_name(p)
|
||||
for p in self._cfg.printers
|
||||
if isinstance(p, dict) and p.get("excluded", False)
|
||||
)
|
||||
cmd = ["/bin/bash", script, filename, "image", "default", str(copies), excluded_list]
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
cmd, capture_output=True, text=True, timeout=120
|
||||
@@ -361,11 +367,13 @@ class PrinterService:
|
||||
statuses = []
|
||||
for p in self._cfg.printers:
|
||||
name = self._printer_name(p)
|
||||
excluded = isinstance(p, dict) and bool(p.get("excluded", False))
|
||||
status = await asyncio.to_thread(self._get_printer_status, name)
|
||||
stats = await self._get_printer_db_stats(name)
|
||||
statuses.append({
|
||||
"name": name,
|
||||
"label": self._printer_label(p),
|
||||
"excluded": excluded,
|
||||
**status,
|
||||
**stats,
|
||||
})
|
||||
@@ -619,8 +627,8 @@ class PrinterService:
|
||||
async def enable_printer(self, printer_name: str) -> bool:
|
||||
"""Active l'imprimante CUPS (cupsenable) et accepte les nouveaux jobs."""
|
||||
try:
|
||||
r1 = subprocess.run(["cupsenable", printer_name], capture_output=True, timeout=10)
|
||||
r2 = subprocess.run(["cupsaccept", printer_name], capture_output=True, timeout=10)
|
||||
r1 = subprocess.run(["sudo", "cupsenable", printer_name], capture_output=True, timeout=10)
|
||||
r2 = subprocess.run(["sudo", "cupsaccept", printer_name], capture_output=True, timeout=10)
|
||||
return r1.returncode == 0 and r2.returncode == 0
|
||||
except Exception as e:
|
||||
logger.error("Erreur enable printer %s: %s", printer_name, e)
|
||||
@@ -629,7 +637,7 @@ class PrinterService:
|
||||
async def disable_printer(self, printer_name: str) -> bool:
|
||||
"""Désactive l'imprimante CUPS (cupsdisable)."""
|
||||
try:
|
||||
result = subprocess.run(["cupsdisable", printer_name], capture_output=True, timeout=10)
|
||||
result = subprocess.run(["sudo", "cupsdisable", printer_name], capture_output=True, timeout=10)
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
logger.error("Erreur disable printer %s: %s", printer_name, e)
|
||||
@@ -638,7 +646,7 @@ class PrinterService:
|
||||
async def reject_jobs(self, printer_name: str) -> bool:
|
||||
"""Refuse les nouveaux jobs (cupsreject) sans stopper l'impression en cours."""
|
||||
try:
|
||||
result = subprocess.run(["cupsreject", printer_name], capture_output=True, timeout=10)
|
||||
result = subprocess.run(["sudo", "cupsreject", printer_name], capture_output=True, timeout=10)
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
logger.error("Erreur reject printer %s: %s", printer_name, e)
|
||||
|
||||
Reference in New Issue
Block a user