From ff5121b7512f4677ddca1e922e4c66ca6b546694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Thu, 26 Oct 2017 12:37:52 +0200 Subject: Fixed error handling --- mensa/backends/satyam.py | 3 ++- mensa/logic.py | 2 ++ setup.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mensa/backends/satyam.py b/mensa/backends/satyam.py index 7ac53a0..e01b546 100644 --- a/mensa/backends/satyam.py +++ b/mensa/backends/satyam.py @@ -21,6 +21,7 @@ class Satyam(IPlugin): response = urllib.request.urlopen(req) the_page = response.read() document = html5lib.parse(the_page, treebuilder="lxml") + sys.stderr = s groupsel = CSSSelector('.news-latest-item-content') k = etree.tostring(groupsel(document)[0]) name = re.sub(r'<.+?>', ' ', str(k)) @@ -29,7 +30,7 @@ class Satyam(IPlugin): name = " ".join(name.split()) name = name.replace("5,95 €", "") - sys.stderr = s + return [Food("Mittagstisch Express", "5,95 €", "Mittagstisch", 2, name[3:-1])] diff --git a/mensa/logic.py b/mensa/logic.py index d2851d5..f14b89c 100755 --- a/mensa/logic.py +++ b/mensa/logic.py @@ -35,6 +35,8 @@ def get_food(restlist=False, options={}) : print(i.human_name + ": No menu found. This could be due to a holiday or due to an error in the script.") except urllib.error.HTTPError as e : print(i.human_name + ": Fetching menu failed: %s" % str(e)) + except : + print(i.human_name + ": Unknown error") return foodl def render(to_render, rendlist=False, options={}) : diff --git a/setup.py b/setup.py index 22085c4..c28954b 100644 --- a/setup.py +++ b/setup.py @@ -10,13 +10,13 @@ def read(fname): setup( name = "mensa", - version = "0.1.2", + version = "0.1.3", author = "Gabriel Pérez-Cerezo", author_email = "gabriel@gpcf.eu", description = ("A program that fetches menus from various restaurants. Pre-installed by default are various cafeterias around TU Berlin."), license = "MIT", keywords = "food", - url = "", + url = "https://gitlab.tu-berlin.de/gpcf/mensa/", packages=['mensa'], scripts=['bin/mensa'], long_description=read('README'), -- cgit v1.2.3