Ajout du fichier requirements.txt
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
# Purges des entrées de toutes les tables dans la base Sondes qui commencent
|
|
||||||
# par Alertes_*** et qui sont agées de plus de sept jours.
|
|
||||||
import mysql.connector
|
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
# Charger les variables d'environnement
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
config = {
|
|
||||||
"host": os.getenv("DB_HOST"),
|
|
||||||
"user": os.getenv("DB_USER"),
|
|
||||||
"password": os.getenv("DB_PASSWORD"),
|
|
||||||
"database": os.getenv("DB_NAME")
|
|
||||||
}
|
|
||||||
|
|
||||||
conn = mysql.connector.connect(**config)
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
# Récupérer toutes les tables d'alertes
|
|
||||||
cursor.execute("SHOW TABLES")
|
|
||||||
tables = [t[0] for t in cursor.fetchall()]
|
|
||||||
alertes_tables = [t for t in tables if t.startswith("Alertes_")]
|
|
||||||
|
|
||||||
# Appliquer la purge à chaque table
|
|
||||||
for table in alertes_tables:
|
|
||||||
query = f"DELETE FROM {table} WHERE Debut_defaut < NOW() - INTERVAL 7 DAY"
|
|
||||||
cursor.execute(query)
|
|
||||||
print(f"✅ Table {table} purgée.")
|
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
cursor.close()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
print("🎉 Purge terminée pour toutes les alertes anciennes.")
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
racine = "." # point de départ = dossier courant
|
|
||||||
|
|
||||||
def detect_fichiers_non_utf8(dossier):
|
|
||||||
for root, dirs, files in os.walk(dossier):
|
|
||||||
for file in files:
|
|
||||||
if file.endswith(".py"):
|
|
||||||
chemin = os.path.join(root, file)
|
|
||||||
try:
|
|
||||||
with open(chemin, encoding="utf-8") as f:
|
|
||||||
f.read()
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
print(f"⚠️ Encodage non UTF-8 : {chemin}")
|
|
||||||
|
|
||||||
detect_fichiers_non_utf8(racine)
|
|
||||||
51
requirements.txt
Normal file
51
requirements.txt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
altair==5.5.0
|
||||||
|
attrs==25.3.0
|
||||||
|
blinker==1.9.0
|
||||||
|
cachetools==5.5.2
|
||||||
|
certifi==2025.4.26
|
||||||
|
charset-normalizer==3.4.2
|
||||||
|
click==8.1.8
|
||||||
|
colorama==0.4.6
|
||||||
|
contourpy==1.3.2
|
||||||
|
cycler==0.12.1
|
||||||
|
dotenv==0.9.9
|
||||||
|
fonttools==4.57.0
|
||||||
|
fpdf==1.7.2
|
||||||
|
gitdb==4.0.12
|
||||||
|
GitPython==3.1.44
|
||||||
|
idna==3.10
|
||||||
|
Jinja2==3.1.6
|
||||||
|
jsonschema==4.23.0
|
||||||
|
jsonschema-specifications==2025.4.1
|
||||||
|
kiwisolver==1.4.8
|
||||||
|
logging==0.4.9.6
|
||||||
|
MarkupSafe==3.0.2
|
||||||
|
matplotlib==3.10.1
|
||||||
|
mysql-connector-python==9.3.0
|
||||||
|
narwhals==1.38.0
|
||||||
|
numpy==2.2.5
|
||||||
|
packaging==24.2
|
||||||
|
paho-mqtt==2.1.0
|
||||||
|
pandas==2.2.3
|
||||||
|
pillow==11.2.1
|
||||||
|
protobuf==6.30.2
|
||||||
|
pyarrow==20.0.0
|
||||||
|
pydeck==0.9.1
|
||||||
|
pyparsing==3.2.3
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
|
python-dotenv==1.1.0
|
||||||
|
pytz==2025.2
|
||||||
|
referencing==0.36.2
|
||||||
|
requests==2.32.3
|
||||||
|
rpds-py==0.24.0
|
||||||
|
schedule==1.2.2
|
||||||
|
six==1.17.0
|
||||||
|
smmap==5.0.2
|
||||||
|
streamlit==1.45.0
|
||||||
|
tenacity==9.1.2
|
||||||
|
toml==0.10.2
|
||||||
|
tornado==6.4.2
|
||||||
|
typing_extensions==4.13.2
|
||||||
|
tzdata==2025.2
|
||||||
|
urllib3==2.4.0
|
||||||
|
watchdog==6.0.0
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import paramiko
|
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
import tkinter as tk
|
|
||||||
from tkinter import messagebox
|
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
HOST = os.getenv("SSH_HOST")
|
|
||||||
USER = os.getenv("SSH_USER")
|
|
||||||
KEY = os.getenv("SSH_KEY")
|
|
||||||
PASSPHRASE = os.getenv("SSH_KEY_PASSPHRASE")
|
|
||||||
|
|
||||||
root = tk.Tk()
|
|
||||||
root.withdraw()
|
|
||||||
|
|
||||||
# 🛡 Vérifie que le fichier existe
|
|
||||||
if not os.path.exists(KEY):
|
|
||||||
messagebox.showerror("❌ Erreur", f"Clé SSH introuvable :\n{KEY}")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
# 🛡 Vérifie que la clé est lisible par paramiko
|
|
||||||
try:
|
|
||||||
paramiko.RSAKey.from_private_key_file(KEY, password=PASSPHRASE)
|
|
||||||
except paramiko.PasswordRequiredException:
|
|
||||||
messagebox.showerror("❌ Clé protégée", "La clé est protégée par une passphrase, mais aucune n'a été fournie.")
|
|
||||||
exit(1)
|
|
||||||
except paramiko.SSHException:
|
|
||||||
messagebox.showerror("❌ Erreur de format", "Le fichier de clé n’est pas au format OpenSSH.\n\nSolution : Exporter depuis PuTTYgen → Conversions > Export OpenSSH key")
|
|
||||||
exit(1)
|
|
||||||
except Exception as e:
|
|
||||||
messagebox.showerror("❌ Autre erreur", f"{e}")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
# ✅ Si la clé est valide, on continue
|
|
||||||
client = paramiko.SSHClient()
|
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
||||||
|
|
||||||
try:
|
|
||||||
client.connect(
|
|
||||||
hostname=HOST,
|
|
||||||
username=USER,
|
|
||||||
key_filename=KEY,
|
|
||||||
passphrase=PASSPHRASE
|
|
||||||
)
|
|
||||||
|
|
||||||
stdin, stdout, stderr = client.exec_command("bash ~/travail/Gestion_sondes/scripts/deploy_all.sh")
|
|
||||||
|
|
||||||
output = stdout.read().decode()
|
|
||||||
errors = stderr.read().decode()
|
|
||||||
|
|
||||||
if "Déploiement complet terminé avec succès" in output:
|
|
||||||
messagebox.showinfo("✅ Déploiement réussi", "Le déploiement s'est bien déroulé.")
|
|
||||||
else:
|
|
||||||
messagebox.showwarning("⚠️ Déploiement incomplet", f"Vérifie les logs :\n\n{errors}")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
messagebox.showerror("❌ Erreur SSH", f"{e}")
|
|
||||||
|
|
||||||
finally:
|
|
||||||
client.close()
|
|
||||||
Reference in New Issue
Block a user