Bladeren bron

Make menu update more resistant to HTTP errors and API changes

Toni Fadjukoff 6 jaren geleden
bovenliggende
commit
76ee24eaa3
1 gewijzigde bestanden met toevoegingen van 10 en 5 verwijderingen
  1. 10 5
      food.py

+ 10 - 5
food.py Bestand weergeven

@@ -39,11 +39,12 @@ unordered = []
39 39
 l = time.localtime()
40 40
 this_week = datetime.datetime.now().isocalendar()[1]
41 41
 
42
-unordered += amica.get_restaurants(use_old, this_week)
43
-unordered += juvenes.get_restaurants(use_old, this_week)
44
-unordered += sodexo.get_restaurants(use_old, this_week)
45
-unordered += campusravita.get_restaurants(use_old, this_week)
46
-
42
+updateException = None
43
+for restaurant_module in [sodexo, amica, juvenes, campusravita]:
44
+    try:
45
+        unordered += restaurant_module.get_restaurants(use_old, this_week)
46
+    except Exception as e:
47
+        updateException = e
47 48
 
48 49
 max_week = 0;
49 50
 for r in unordered:
@@ -411,3 +412,7 @@ all_restaurants = get_restaurants_sorted(unordered);
411 412
 
412 413
 write_all_days(all_restaurants, "", all_title, "");
413 414
 write_table(all_restaurants, "", all_title, "");
415
+
416
+if updateException is not None:
417
+    print("Exception happened while fetching menus")
418
+    raise updateException