From 92a3578b2b7bc77a19c2e6df0de9f810324dd4f6 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 26 Apr 2021 15:45:55 +0200 Subject: [PATCH] Mes choix de centre --- bot.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bot.py b/bot.py index cc5fe53..7b1d757 100755 --- a/bot.py +++ b/bot.py @@ -10,9 +10,9 @@ import requests import smtplib -# API_PREFIX = "https://beta.interieur.gouv.fr/candilib/api/v2/" +API_PREFIX = "https://beta.interieur.gouv.fr/candilib/api/v2/" # API_PREFIX = "https://candilib.ynerant.fr/candilib/api/v2/" -API_PREFIX = "http://localhost/candilib/api/v2/" +# API_PREFIX = "http://localhost/candilib/api/v2/" CAPTCHA_IMAGES = { "L'avion": "airplane", @@ -168,14 +168,15 @@ def main(token: str) -> None: dpt.count += centre.count places = Places(**api('places', token, user_id)) - for dpt in departements: - for centre in dpt.centres: - if centre._id == places.centre['_id']: - places.centre = centre - break - else: - continue - break + if places.centre: + for dpt in departements: + for centre in dpt.centres: + if centre._id == places.centre['_id']: + places.centre = centre + break + else: + continue + break if places.date: print(f"Vous avez déjà une date d'examen, le {places.date}.") @@ -191,7 +192,8 @@ def main(token: str) -> None: send_mail(json.dumps(dates, indent=2), centre.nom) centre.dates = dates - PREFERRED_CENTRES = ["MASSY", "RUNGIS", "ETAMPES", "SAINT CLOUD", "SAINT PRIEST"] + PREFERRED_CENTRES = ["MASSY", "ANTONY", "RUNGIS", "MONTGERON", "CLAMART", "SAINT CLOUD", "EVRY", + "VILLABE", "ETAMPES", "VELIZY VILLACOUBLAY", "MAISONS ALFORT", "TRAPPES", "SAINT PRIEST"] for name in PREFERRED_CENTRES: for dpt in departements: