From ba4f5d7d4f7dc7a8eb00194f7624850462f69dab Mon Sep 17 00:00:00 2001 From: Michel Date: Sat, 26 Apr 2025 21:50:05 +0200 Subject: [PATCH] Ajout ou correction sur develop___21:49 --- Monitor.py | 2 +- domo91.py | 43 ++++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Monitor.py b/Monitor.py index 2a9dbdc..6354616 100644 --- a/Monitor.py +++ b/Monitor.py @@ -141,7 +141,7 @@ def surveiller(): if log_entries: df_logs = pd.DataFrame(log_entries) - df_logs.to_csv("/home/debian/travail/Gestion_sondes/Logs/monitor.csv", sep=";", index=False) + df_logs.to_csv("/var/log/monitor.csv", sep=";", index=False) except Exception as e: print(f"Erreur : {e}", flush=True) diff --git a/domo91.py b/domo91.py index c884351..dafa8d5 100644 --- a/domo91.py +++ b/domo91.py @@ -511,27 +511,28 @@ if st.session_state["authenticated"]: except Exception as e: st.error(f"Erreur SQL (admin) : {e}") + # --- ONGLET TRAFFIC ------ -elif onglet == "Traffic": - st.markdown("## 🚦 Connexions récentes") - try: - conn = mysql.connector.connect(**db_config) - cursor = conn.cursor(dictionary=True) - cursor.execute( - "SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200" - ) - connexions = cursor.fetchall() - cursor.close() - conn.close() + elif onglet == "Traffic": + st.markdown("## 🚦 Connexions récentes") + try: + conn = mysql.connector.connect(**db_config) + cursor = conn.cursor(dictionary=True) + cursor.execute( + "SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200" + ) + connexions = cursor.fetchall() + cursor.close() + conn.close() - if connexions: - df_connexions = pd.DataFrame(connexions) - st.success(f"{len(df_connexions)} connexions trouvées.") # Compteur affiché proprement - st.dataframe(df_connexions, use_container_width=True) - else: - st.info("Aucune connexion enregistrée.") - except Exception as e: - st.error(f"Erreur chargement des connexions : {e}") + if connexions: + df_connexions = pd.DataFrame(connexions) + st.dataframe(df_connexions, use_container_width=True) + else: + st.info("Aucune connexion enregistrée.") + except Exception as e: + st.error(f"Erreur chargement des connexions : {e}") + + except Exception as err: # petit bug dans ton except ici (tu avais écrit "except exception") + st.error(f"Erreur MySQL : {err}") - except Exception as err: - st.error(f"Erreur MySQL : {err}") \ No newline at end of file