[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
This commit is contained in:
parent
fcbb899e2f
commit
210075fdf9
1 changed files with 8 additions and 2 deletions
|
@ -18,8 +18,10 @@ APT_CHECK_PATH = "/usr/lib/update-notifier/apt_check.py"
|
||||||
def get_apt_check_info(widget):
|
def get_apt_check_info(widget):
|
||||||
try:
|
try:
|
||||||
res = bumblebee.util.execute(APT_CHECK_PATH)
|
res = bumblebee.util.execute(APT_CHECK_PATH)
|
||||||
except RuntimeError:
|
widget.set("error", None)
|
||||||
pass
|
except (RuntimeError, FileNotFoundError) as e:
|
||||||
|
widget.set("error", "unable to query APT: {}".format(e))
|
||||||
|
return
|
||||||
|
|
||||||
all_pkg = 0
|
all_pkg = 0
|
||||||
security = 0
|
security = 0
|
||||||
|
@ -46,6 +48,8 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
def updates(self, widget):
|
def updates(self, widget):
|
||||||
result = []
|
result = []
|
||||||
|
if widget.get("error"):
|
||||||
|
return widget.get("error")
|
||||||
for t in ["all_pkg", "security"]:
|
for t in ["all_pkg", "security"]:
|
||||||
result.append(str(widget.get(t, 0)))
|
result.append(str(widget.get(t, 0)))
|
||||||
return "/".join(result)
|
return "/".join(result)
|
||||||
|
@ -63,6 +67,8 @@ class Module(bumblebee.engine.Module):
|
||||||
ret = "critical"
|
ret = "critical"
|
||||||
elif cnt > 0:
|
elif cnt > 0:
|
||||||
ret = "warning"
|
ret = "warning"
|
||||||
|
if widget.get("error"):
|
||||||
|
ret = "critical"
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue