From 958cd6a59bca2b0cddd8258b47709b1630d5a34f Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Wed, 8 Aug 2018 19:54:51 +0200 Subject: [PATCH] ajout de l'option --force et du check regen --- main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.py b/main.py index 3f04c5f..aa19966 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ from django.core.mail import send_mail from django.template import loader, Context from pprint import pprint +import sys config = ConfigParser() config.read('config.ini') @@ -19,6 +20,10 @@ api_client = Re2oAPIClient(api_hostname,api_username,api_password) client_hostname = socket.gethostname().split('.',1)[0] +for arg in sys.argv: + if arg=="--force": + notif_end_adhesion(api_client) + def notif_end_adhesion(api_client): asso_options = api_client.list("preferences/assooption") from_mail = api_client.list("preferences/generaloption")["email_from"] @@ -40,3 +45,10 @@ def notif_end_adhesion(api_client): html_message = template.render(context) ) + +for service in api_client.list("services/regen/"): + if service['hostname'] == client_hostname and \ + service['service_name'] == 'mail' and \ + service['need_regen']: + notif_end_adhesion(api_client) + api_client.patch(service['api_url'], data={'need_regen': False})