[HandBrake_recursive] Ajout des inhibiteurs
This commit is contained in:
parent
10ffd3a583
commit
7086cae208
@ -10,10 +10,65 @@ import json
|
|||||||
import argparse
|
import argparse
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
|
|
||||||
|
import pydbus as dbus
|
||||||
|
|
||||||
import openpyxl
|
import openpyxl
|
||||||
from openpyxl.styles import PatternFill
|
from openpyxl.styles import PatternFill
|
||||||
from openpyxl.formatting.rule import CellIsRule
|
from openpyxl.formatting.rule import CellIsRule
|
||||||
|
|
||||||
|
def inhibit_arret(application, raison):
|
||||||
|
inhibiteurs = {}
|
||||||
|
|
||||||
|
# Inhibition arrêt et veille via login1 (SystemBus)
|
||||||
|
system_bus = dbus.SystemBus()
|
||||||
|
login1 = system_bus.get("org.freedesktop.login1", "/org/freedesktop/login1")
|
||||||
|
|
||||||
|
inhibiteurs["shutdown"] = login1.Inhibit(
|
||||||
|
"shutdown",
|
||||||
|
application,
|
||||||
|
raison,
|
||||||
|
"block"
|
||||||
|
)
|
||||||
|
inhibiteurs["sleep"] = login1.Inhibit(
|
||||||
|
"sleep",
|
||||||
|
application,
|
||||||
|
raison,
|
||||||
|
"block"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Inhibition déconnexion via gnome-session (SessionBus)
|
||||||
|
session_bus = dbus.SessionBus()
|
||||||
|
session_manager = session_bus.get("org.gnome.SessionManager", "/org/gnome/SessionManager")
|
||||||
|
|
||||||
|
# flags:
|
||||||
|
# 0 = logout only
|
||||||
|
# 1 = user switch
|
||||||
|
# 2 = suspend
|
||||||
|
# 4 = shutdown
|
||||||
|
# 8 = idle (screensaver, etc)
|
||||||
|
flags = 0 | 1 | 2 | 4 | 8
|
||||||
|
inhibiteurs["session"] = session_manager.Inhibit(
|
||||||
|
application,
|
||||||
|
0,
|
||||||
|
raison,
|
||||||
|
flags
|
||||||
|
)
|
||||||
|
|
||||||
|
return inhibiteurs
|
||||||
|
|
||||||
|
def lever_inhibit_arret(inhibiteurs):
|
||||||
|
# Fermer le descripteur de fichier pour lever l'inhibition
|
||||||
|
for cle, inhibiteur in inhibiteurs.items():
|
||||||
|
if cle in ["shutdown", "sleep"] and hasattr(inhibiteur, "close"):
|
||||||
|
inhibiteur.close()
|
||||||
|
elif cle == "session":
|
||||||
|
# Connexion au bus session
|
||||||
|
session_bus = dbus.SessionBus()
|
||||||
|
# Obtenir l'interface SessionManager de gnome
|
||||||
|
session_manager = session_bus.get("org.gnome.SessionManager", "/org/gnome/SessionManager")
|
||||||
|
session_manager.Uninhibit(inhibiteur)
|
||||||
|
|
||||||
|
|
||||||
# Définir la largeur de chaque colonne à environ 3 cm (approximativement 10.5 unités)
|
# Définir la largeur de chaque colonne à environ 3 cm (approximativement 10.5 unités)
|
||||||
def set_column_width(ws, column_range, width=15):
|
def set_column_width(ws, column_range, width=15):
|
||||||
for col in column_range:
|
for col in column_range:
|
||||||
@ -380,6 +435,8 @@ def main():
|
|||||||
# Liste pour enregistrer le résumé
|
# Liste pour enregistrer le résumé
|
||||||
lignes = []
|
lignes = []
|
||||||
|
|
||||||
|
inhibiteurs = inhibit_arret( "HandBrake Script", "Encodage vidéo en cours")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Traitement de chaque fichier vidéo
|
# Traitement de chaque fichier vidéo
|
||||||
for video_file in video_files:
|
for video_file in video_files:
|
||||||
@ -458,11 +515,14 @@ def main():
|
|||||||
"" # Résultat
|
"" # Résultat
|
||||||
))
|
))
|
||||||
|
|
||||||
# Affichage du résumé
|
|
||||||
afficher_tableau(lignes, use_pager=use_pager)
|
|
||||||
xlsx_file = "résumé.xlsx"
|
xlsx_file = "résumé.xlsx"
|
||||||
export_xlsx(lignes, fichier_sortie=xlsx_file)
|
export_xlsx(lignes, fichier_sortie=xlsx_file)
|
||||||
print(f"📝 Classeur généré : {xlsx_file}")
|
print(f"📝 Classeur généré : {xlsx_file}")
|
||||||
|
|
||||||
|
lever_inhibit_arret(inhibiteurs)
|
||||||
|
|
||||||
|
# Affichage du résumé
|
||||||
|
afficher_tableau(lignes, use_pager=use_pager)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user