Supprimer run_deploy.py
This commit is contained in:
@@ -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