61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
import logging
|
|
import subprocess
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def run(message, encours):
|
|
|
|
|
|
email_kaz = message["email_kaz"]
|
|
|
|
commandes = []
|
|
|
|
if message.get("modifier_mdp", False):
|
|
script = "/kaz/bin/gestUsers.sh"
|
|
commandes.append([script, "-r", email_kaz])
|
|
|
|
if message.get("modifier_email_secours", False):
|
|
script = "/kaz/bin/update-ldap-paheko.sh"
|
|
commandes.append([ script, "-u", email_kaz, "-s",message["email_secours"] ])
|
|
|
|
if message.get("modifier_tel", False):
|
|
script = "/kaz/bin/update-ldap-paheko.sh"
|
|
commandes.append([ script, "-u", email_kaz, "-m",message["telephone"] ])
|
|
|
|
if message.get("modifier_quota", False):
|
|
script = "/kaz/bin/update-ldap-paheko.sh"
|
|
commandes.append([ script, "-u", email_kaz, "-q",message["quota_disque"] ])
|
|
|
|
if message.get("supprimer_membre", False):
|
|
script = "/kaz/bin/gestUsers.sh"
|
|
commandes.append([script, "-d", email_kaz])
|
|
|
|
for command in commandes:
|
|
|
|
log.info(
|
|
f"Exécution : {' '.join(command)}"
|
|
)
|
|
|
|
result = subprocess.run(
|
|
command,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
if result.stdout:
|
|
log.info(
|
|
f"Résultat du script :\n{result.stdout}"
|
|
)
|
|
|
|
if result.stderr:
|
|
log.warning(
|
|
f"Sortie stderr du script :\n{result.stderr}"
|
|
)
|
|
|
|
if result.returncode != 0:
|
|
raise RuntimeError(
|
|
f"Le script a échoué avec le code "
|
|
f"{result.returncode} : {' '.join(command)}"
|
|
)
|