diff --git a/bin/worker_actions/modifier_compte.py b/bin/worker_actions/modifier_compte.py new file mode 100644 index 0000000..966775a --- /dev/null +++ b/bin/worker_actions/modifier_compte.py @@ -0,0 +1,64 @@ +import logging +import subprocess + +log = logging.getLogger(__name__) + + +def run(message, encours): + + script = "gestUser.sh" + email_kaz = message["email_kaz"] + + commandes = [] + + if message.get("modifier_mdp", False): + commandes.append([script, "-r", email_kaz]) + + if message.get("modifier_email_secours", False): + commandes.append([ + script, "-s", email_kaz, + message["email_secours"] + ]) + + if message.get("modifier_tel", False): + commandes.append([ + script, "-t", email_kaz, + message["telephone"] + ]) + + if message.get("modifier_quota", False): + commandes.append([ + script, "-q", email_kaz, + str(message["quota_disque"]) + ]) + + if message.get("supprimer_membre", False): + 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)}" + ) diff --git a/bin/worker_actions/modifier_services.py b/bin/worker_actions/modifier_services.py index 21ebaf3..00a0a04 100644 --- a/bin/worker_actions/modifier_services.py +++ b/bin/worker_actions/modifier_services.py @@ -14,8 +14,8 @@ import subprocess # ], # "nom_court_orga": "monorga11", # "emails": [ -# "admin@kaz.bzh", -# "contact@kaz.bzh" +# "titi@toto.fr", +# "tata@toto.fr" # ] # }