From 4260ca0e92315cec8aeb3f0b5da762550316a05a Mon Sep 17 00:00:00 2001 From: paulmart-n Date: Mon, 22 Jan 2024 18:10:41 +0100 Subject: [PATCH] Mensa-Fix --- fetchDUALIS.py | 1 - fetchMENSA.py | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fetchDUALIS.py b/fetchDUALIS.py index 1b92b65..cfe7fbe 100644 --- a/fetchDUALIS.py +++ b/fetchDUALIS.py @@ -144,7 +144,6 @@ def getPruefung(url): col = [e.text.strip() for e in cols] if len(col) == 6 and len(col[3]) <= 13: if len(col[3]) != 0: - print (col) ret += [col[0] + ": " + col[3][:3]] if ret[-1][0] == ':': ret[-1] = "Gesamt" + ret[-1] diff --git a/fetchMENSA.py b/fetchMENSA.py index 1189008..0e2fa6c 100644 --- a/fetchMENSA.py +++ b/fetchMENSA.py @@ -40,7 +40,6 @@ def getMealsFromAPI(day: str, dbentry: bool = False): response = response.content jres = json.loads(response.decode("utf-8")) essen = [] - try: num = len(jres["data"][0]["lines"]) for i in range(num): @@ -67,7 +66,7 @@ def getMealsFromAPI(day: str, dbentry: bool = False): essen += [name] if dbentry: - mid = int(time.time()*1000) % 100000 + mid = int(time.time() * 1000) % 100000 neu = Meals(date=day, name=name, id=mid, vegan=vegan, vegetarian=veget, schwein=schwein) db.session.add(neu) db.session.commit() @@ -99,11 +98,15 @@ def formatDay(day: datetime): :param day: :return str: """ + if day.month < 10: + mon = "0" + str(day.month) + else: + mon = str(day.month) if day.day < 10: tag = "0" + str(day.day) else: tag = str(day.day) - day = str(day.year) + "-" + str(day.month) + "-" + tag + day = str(day.year) + "-" + mon + "-" + tag return day @@ -128,7 +131,7 @@ def refreshMeals(): dbnames = [] for m in dbmeals: dbnames += [m.name] - if set (dbnames) != set(apinames) and nomeal not in apinames: + if set(dbnames) != set(apinames) and nomeal not in apinames: for n in dbnames: db.session.delete(Meals.query.filter_by(date=i, name=n).first()) db.session.commit()