2016-11-24 19:01:48 +01:00
|
|
|
import bumblebee.module
|
|
|
|
import subprocess
|
|
|
|
import os
|
|
|
|
|
|
|
|
def description():
|
|
|
|
return "Displays available updates per repository for pacman."
|
|
|
|
|
|
|
|
class Module(bumblebee.module.Module):
|
2016-12-02 18:53:34 +01:00
|
|
|
def __init__(self, output, config):
|
|
|
|
super(Module, self).__init__(output, config)
|
2016-11-24 19:01:48 +01:00
|
|
|
self._count = 0
|
|
|
|
|
|
|
|
def widgets(self):
|
2016-11-25 17:10:02 +01:00
|
|
|
path = os.path.dirname(os.path.abspath(__file__))
|
2016-11-24 19:01:48 +01:00
|
|
|
if self._count == 0:
|
|
|
|
self._out = "?/?/?/?"
|
2016-11-25 17:10:02 +01:00
|
|
|
process = subprocess.Popen([ "{}/../../bin/customupdates".format(path) ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
2016-11-24 19:01:48 +01:00
|
|
|
|
|
|
|
self._query, self._error = process.communicate()
|
|
|
|
|
|
|
|
if not process.returncode == 0:
|
|
|
|
self._out = "?/?/?/?"
|
|
|
|
else:
|
|
|
|
self._community = 0
|
|
|
|
self._core = 0
|
|
|
|
self._extra = 0
|
|
|
|
self._other = 0
|
|
|
|
|
|
|
|
for line in self._query.splitlines():
|
|
|
|
if line.startswith(b'http'):
|
|
|
|
if b"community" in line:
|
|
|
|
self._community += 1
|
|
|
|
continue
|
|
|
|
if b"core" in line:
|
|
|
|
self._core += 1;
|
|
|
|
continue
|
|
|
|
if b"extra" in line:
|
|
|
|
self._extra += 1
|
|
|
|
continue
|
|
|
|
self._other += 1
|
|
|
|
self._out = str(self._core)+"/"+str(self._extra)+"/"+str(self._community)+"/"+str(self._other)
|
|
|
|
|
|
|
|
self._count += 1
|
|
|
|
self._count = 0 if self._count > 300 else self._count
|
|
|
|
return bumblebee.output.Widget(self, "{}".format(self._out))
|
|
|
|
|
|
|
|
def sumUpdates(self):
|
|
|
|
return self._core + self._community + self._extra + self._other
|
|
|
|
|
|
|
|
def critical(self, widget):
|
|
|
|
#return self._sumUpdates(self)
|
|
|
|
return self.sumUpdates() > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|