From b170b260ebf0d70760d71a1360ba9841f639b171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Badst=C3=BCbner?= Date: Tue, 11 Jun 2024 14:02:19 +0200 Subject: [PATCH] fix(modules,contrib,thunderbird): show not-found message; fix whitespace in inbox name --- bumblebee_status/modules/contrib/thunderbird.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bumblebee_status/modules/contrib/thunderbird.py b/bumblebee_status/modules/contrib/thunderbird.py index 494ff427..e4dc6658 100644 --- a/bumblebee_status/modules/contrib/thunderbird.py +++ b/bumblebee_status/modules/contrib/thunderbird.py @@ -35,7 +35,9 @@ def __init__(self, config, theme): self.__home = self.parameter("home", "") inboxes = self.parameter("inboxes", "") if inboxes: - self.__inboxes = util.format.aslist(inboxes) + # we can not use utils.format.aslist here + # because we need the whitespace in inbox name + self.__inboxes = inboxes.split(",") def thunderbird(self, _): return str(self.__label) @@ -50,6 +52,10 @@ def update(self): counts = [] for inbox in self.__inboxes: + if not inbox in unread: + counts.append("-not-found-") + continue + count = unread[inbox] self.__total += int(count) counts.append(count) @@ -63,10 +69,10 @@ def __getThunderbirdStream(self): cmd = ( "find " + self.__home - + " -name '*.msf' -exec grep -aREo '\^A1=[0-9a-fA-F]+)' {} + | grep" + + " -name '*.msf' -exec grep -aREo '\\^A1=[0-9a-fA-F]+)' {} + | grep" ) for inbox in self.__inboxes: - cmd += " -e {}".format(inbox) + cmd += " -e \"{}\"".format(inbox) cmd += "| awk -F / '{print $(NF-1)\"/\"$(NF)}'" return util.cli.execute(cmd, shell=True).strip().split("\n") @@ -75,6 +81,9 @@ def __getUnreadMessagesByInbox(self, stream): unread = {} for line in stream: entry = line.split(":^A1=") + if len(entry) < 2: + continue + inbox = entry[0] count = str(int(entry[1][:-1], 16)) unread[inbox] = count