From 210075fdf96df07895427e4fa04f68ebdf566be8 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 6 Jun 2019 20:14:16 +0200 Subject: [PATCH] [modules/apt] Show error if unable to query APT If querying APT fails for some reason, show an error message and set the state of the widget to critical. fixes #395 --- bumblebee/modules/apt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/apt.py b/bumblebee/modules/apt.py index ab8f227..dc5fac8 100644 --- a/bumblebee/modules/apt.py +++ b/bumblebee/modules/apt.py @@ -18,8 +18,10 @@ APT_CHECK_PATH = "/usr/lib/update-notifier/apt_check.py" def get_apt_check_info(widget): try: res = bumblebee.util.execute(APT_CHECK_PATH) - except RuntimeError: - pass + widget.set("error", None) + except (RuntimeError, FileNotFoundError) as e: + widget.set("error", "unable to query APT: {}".format(e)) + return all_pkg = 0 security = 0 @@ -46,6 +48,8 @@ class Module(bumblebee.engine.Module): def updates(self, widget): result = [] + if widget.get("error"): + return widget.get("error") for t in ["all_pkg", "security"]: result.append(str(widget.get(t, 0))) return "/".join(result) @@ -63,6 +67,8 @@ class Module(bumblebee.engine.Module): ret = "critical" elif cnt > 0: ret = "warning" + if widget.get("error"): + ret = "critical" return ret