fix and simplify pacman.py

This commit is contained in:
Von Random 2019-01-31 14:19:43 +03:00
parent 6fc4d3176d
commit e33bf61a30

View file

@ -9,13 +9,9 @@ class PluginThread(plugins.PluginThreadCommon):
'problem': 10 'problem': 10
} }
super(PluginThread, self).__init__(config, defaults) super(PluginThread, self).__init__(config, defaults)
self.format_status(list()) self.format_status(0)
def format_status(self, updates): def format_status(self, count):
count = int()
for update in updates:
if not '[ignored]' in update:
count += 1
self.hide = count == 0 self.hide = count == 0
self.status['urgent'] = count >= self.conf['problem'] self.status['urgent'] = count >= self.conf['problem']
self.status['full_text'] = 'UPD: ' + str(count) self.status['full_text'] = 'UPD: ' + str(count)
@ -25,5 +21,6 @@ class PluginThread(plugins.PluginThreadCommon):
('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE, ('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
) )
out = str(pacman_qu.communicate()[0]) out = pacman_qu.communicate()[0].strip().splitlines()
self.format_status(out.splitlines()) packages = [pkg for pkg in out if not '[ignored]' in pkg]
self.format_status(len(packages))