From c77b166a9d6b43a4508239c19679b73806a53fe7 Mon Sep 17 00:00:00 2001 From: antux18 Date: Sun, 31 Mar 2024 17:53:14 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20d'un=20bug=20qui=20emp=C3=AAchait?= =?UTF-8?q?=20de=20d=C3=A9marrer=20si=20le=20fichier=20des=20logs=20est=20?= =?UTF-8?q?invalide.=20Commentaires.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 6 +++++- rooms_get.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 5928dfa..99a23d9 100644 --- a/app.py +++ b/app.py @@ -76,7 +76,11 @@ app = Flask(__name__) logs = [] if os.path.isfile(LOG_FILE): with open(LOG_FILE,"r") as f: - logs = json.loads(f.read()) + try: + logs = json.loads(f.read()) + # On supprime le fichier s'il est invalide : + except json.decoder.JSONDecodeError: + os.remove(LOG_FILE) # Fonctions : def save_logs(logs): diff --git a/rooms_get.py b/rooms_get.py index b66cdc7..c27354c 100644 --- a/rooms_get.py +++ b/rooms_get.py @@ -245,7 +245,8 @@ def get_tot_rooms(datet, depts, ignore_list) : margintime = 1 # Récupération du calendrier de chaque département, - # sur une période de 'margintime' mois : + # sur une période de 'margintime' mois. + # On choisit comme jour le 28, car tous les mois ont au moins 28 jours. cals = list() # Liste des EDT des départements choisis for d in depts : if datet.month < 12 :