From ea4357b636e59f5dbe8104bc6d1a8c90552b908e Mon Sep 17 00:00:00 2001 From: Michel Date: Thu, 17 Apr 2025 14:45:57 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20domo91.py=20depuis?= =?UTF-8?q?=20develop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domo91.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/domo91.py b/domo91.py index 26f5fe7..4473fe9 100644 --- a/domo91.py +++ b/domo91.py @@ -18,7 +18,6 @@ db_config = { "password": "#SO2&1nf%mZ@jfh", "database": "Sondes" } - # --- Fonction de génération PDF --- def generer_pdf(site, date_str): st.info(f"Génération du rapport PDF pour {site} à la date {date_str}") @@ -81,7 +80,10 @@ def generer_pdf(site, date_str): pdf.alertes_section(alertes) file_name = f"rapport_{site}_{date_str}.pdf" - output_path = os.path.join("PDF", file_name) + output_dir = "PDF" + os.makedirs(output_dir, exist_ok=True) # 🔧 Crée le dossier si absent + output_path = os.path.join(output_dir, file_name) + pdf.output(output_path) with open(output_path, "rb") as f: @@ -94,7 +96,6 @@ def generer_pdf(site, date_str): except Exception as e: st.error(f"Erreur lors de la génération du PDF : {e}") - # --- Initialisation session --- if "authenticated" not in st.session_state: st.session_state["authenticated"] = False @@ -199,3 +200,4 @@ if st.session_state["authenticated"]: except Exception as e: st.error(f"Erreur MySQL : {e}") +