2017-01-12 15:56:32 +02:00
|
|
|
import plugins
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
2018-04-28 19:40:10 +03:00
|
|
|
defaults = {
|
|
|
|
'freq': 15,
|
|
|
|
'problem': 10
|
|
|
|
}
|
2017-12-16 01:55:28 +02:00
|
|
|
super(PluginThread, self).__init__(config, defaults)
|
2019-01-16 13:46:52 +02:00
|
|
|
self.format_status(list())
|
2017-01-12 15:56:32 +02:00
|
|
|
|
2019-01-16 13:46:52 +02:00
|
|
|
def format_status(self, updates):
|
|
|
|
count = int()
|
|
|
|
for update in updates:
|
|
|
|
if not '[ignored]' in update:
|
|
|
|
count += 1
|
2018-04-28 19:40:10 +03:00
|
|
|
self.hide = count == 0
|
|
|
|
self.status['urgent'] = count >= self.conf['problem']
|
2019-01-16 13:46:52 +02:00
|
|
|
self.status['full_text'] = 'UPD: ' + str(count)
|
2017-01-12 15:56:32 +02:00
|
|
|
|
|
|
|
def main(self):
|
2019-01-16 13:46:52 +02:00
|
|
|
pacman_qu = subprocess.Popen(
|
|
|
|
('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
|
|
|
|
)
|
|
|
|
out = str(pacman_qu.communicate()[0])
|
|
|
|
self.format_status(out.splitlines())
|