From 1cc6a56dfa49df42ffa80c75a58824c2adbaeec6 Mon Sep 17 00:00:00 2001 From: Michel Date: Tue, 6 May 2025 13:52:13 +0000 Subject: [PATCH] Supprimer run_deploy.py --- run_deploy.py | 61 --------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 run_deploy.py diff --git a/run_deploy.py b/run_deploy.py deleted file mode 100644 index 98ccf01..0000000 --- a/run_deploy.py +++ /dev/null @@ -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()