[modules] weather & github: Protect against missing data
If data cannot be retrieved for some reason (be pretty generous about that by catching generic exceptions), instead of terminating the whole status bar, simply report unknown data. see #110
This commit is contained in:
parent
b89e384b20
commit
dc06611fb1
2 changed files with 10 additions and 4 deletions
|
@ -44,9 +44,13 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
notifications = requests.get("https://api.github.com/notifications", headers={"Authorization":"token {}".format(token)}).text
|
notifications = requests.get("https://api.github.com/notifications", headers={"Authorization":"token {}".format(token)}).text
|
||||||
unread = 0
|
unread = 0
|
||||||
for notification in json.loads(notifications):
|
try:
|
||||||
if "unread" in notification and notification["unread"]:
|
for notification in json.loads(notifications):
|
||||||
unread += 1
|
if "unread" in notification and notification["unread"]:
|
||||||
self._count = unread
|
unread += 1
|
||||||
|
self._count = unread
|
||||||
|
except Exception:
|
||||||
|
self._count = "n/a"
|
||||||
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
|
@ -70,5 +70,7 @@ class Module(bumblebee.engine.Module):
|
||||||
self._valid = True
|
self._valid = True
|
||||||
except RequestException:
|
except RequestException:
|
||||||
self._valid = False
|
self._valid = False
|
||||||
|
except Exception:
|
||||||
|
self._valid = False
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue