summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVon Random <von@vdrandom.org>2019-01-31 14:19:43 +0300
committerVon Random <von@vdrandom.org>2019-01-31 14:19:43 +0300
commite33bf61a3049ffcc89d2b999fd6306e3292cfea3 (patch)
treed36c9af16bd68fed8461350d452061ec4f7ac91b
parent6fc4d3176de95cabebd826b6942f8612b0083dec (diff)
fix and simplify pacman.py
-rw-r--r--plugins/pacman.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/plugins/pacman.py b/plugins/pacman.py
index 148db8c..cd6c5e5 100644
--- a/plugins/pacman.py
+++ b/plugins/pacman.py
@@ -9,13 +9,9 @@ class PluginThread(plugins.PluginThreadCommon):
'problem': 10
}
super(PluginThread, self).__init__(config, defaults)
- self.format_status(list())
+ self.format_status(0)
- def format_status(self, updates):
- count = int()
- for update in updates:
- if not '[ignored]' in update:
- count += 1
+ def format_status(self, count):
self.hide = count == 0
self.status['urgent'] = count >= self.conf['problem']
self.status['full_text'] = 'UPD: ' + str(count)
@@ -25,5 +21,6 @@ class PluginThread(plugins.PluginThreadCommon):
('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
)
- out = str(pacman_qu.communicate()[0])
- self.format_status(out.splitlines())
+ out = pacman_qu.communicate()[0].strip().splitlines()
+ packages = [pkg for pkg in out if not '[ignored]' in pkg]
+ self.format_status(len(packages))