"Fichier de mise à jour"
This commit is contained in:
43
run_deploy.py
Normal file
43
run_deploy.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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")
|
||||||
|
|
||||||
|
client = paramiko.SSHClient()
|
||||||
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
|
||||||
|
try:
|
||||||
|
client.connect(hostname=HOST, username=USER, key_filename=KEY)
|
||||||
|
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:
|
||||||
|
success = True
|
||||||
|
else:
|
||||||
|
success = False
|
||||||
|
|
||||||
|
# Affichage de la notification visuelle
|
||||||
|
root = tk.Tk()
|
||||||
|
root.withdraw() # cache la fenêtre principale
|
||||||
|
|
||||||
|
if success:
|
||||||
|
messagebox.showinfo("Déploiement terminé", "✅ Le déploiement s'est bien déroulé !")
|
||||||
|
else:
|
||||||
|
messagebox.showwarning("Déploiement partiel", f"⚠️ Déploiement incomplet. Vérifiez les logs.\n\n{errors}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
root = tk.Tk()
|
||||||
|
root.withdraw()
|
||||||
|
messagebox.showerror("Erreur SSH", f"❌ Erreur : {e}")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
client.close()
|
||||||
Reference in New Issue
Block a user