Browse Source

Make menu update more resistant to HTTP errors and API changes

Toni Fadjukoff 5 years ago
parent
commit
76ee24eaa3
1 changed files with 10 additions and 5 deletions
  1. 10 5
      food.py

+ 10 - 5
food.py View File

39
 l = time.localtime()
39
 l = time.localtime()
40
 this_week = datetime.datetime.now().isocalendar()[1]
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
 max_week = 0;
49
 max_week = 0;
49
 for r in unordered:
50
 for r in unordered:
411
 
412
 
412
 write_all_days(all_restaurants, "", all_title, "");
413
 write_all_days(all_restaurants, "", all_title, "");
413
 write_table(all_restaurants, "", all_title, "");
414
 write_table(all_restaurants, "", all_title, "");
415
+
416
+if updateException is not None:
417
+    print("Exception happened while fetching menus")
418
+    raise updateException