Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modules,contrib,thunderbird): show not-found message; fix whitespace in inbox name #1025

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bumblebee_status/modules/contrib/thunderbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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")
Expand All @@ -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
Expand Down
Loading