[modules/dnf] Update to latest API
This commit is contained in:
parent
9a6e044218
commit
7ffb8f1e7a
1 changed files with 15 additions and 17 deletions
|
@ -12,23 +12,21 @@ Parameters:
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import bumblebee.util
|
import core.event
|
||||||
import bumblebee.input
|
import core.module
|
||||||
import bumblebee.output
|
import core.widget
|
||||||
import bumblebee.engine
|
import core.decorators
|
||||||
|
|
||||||
|
import util.cli
|
||||||
|
|
||||||
def get_dnf_info(widget):
|
def get_dnf_info(widget):
|
||||||
try:
|
res = util.cli.execute('dnf updateinfo', ignore_errors=True)
|
||||||
res = bumblebee.util.execute('dnf updateinfo')
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
security = 0
|
security = 0
|
||||||
bugfixes = 0
|
bugfixes = 0
|
||||||
enhancements = 0
|
enhancements = 0
|
||||||
other = 0
|
other = 0
|
||||||
for line in res.split('\n'):
|
for line in res.split('\n'):
|
||||||
|
|
||||||
if not line.startswith(' '): continue
|
if not line.startswith(' '): continue
|
||||||
elif 'ecurity' in line:
|
elif 'ecurity' in line:
|
||||||
for s in line.split():
|
for s in line.split():
|
||||||
|
@ -48,12 +46,12 @@ def get_dnf_info(widget):
|
||||||
widget.set('enhancements', enhancements)
|
widget.set('enhancements', enhancements)
|
||||||
widget.set('other', other)
|
widget.set('other', other)
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
core.event.trigger('update', [ widget.module().id ], redraw_only=True)
|
||||||
def __init__(self, engine, config):
|
|
||||||
widget = bumblebee.output.Widget(full_text=self.updates)
|
class Module(core.module.Module):
|
||||||
super(Module, self).__init__(engine, config, widget)
|
@core.decorators.every(minutes=30)
|
||||||
self.interval_factor(60)
|
def __init__(self, config):
|
||||||
self.interval(30)
|
super().__init__(config, core.widget.Widget(self.updates))
|
||||||
|
|
||||||
def updates(self, widget):
|
def updates(self, widget):
|
||||||
result = []
|
result = []
|
||||||
|
@ -61,8 +59,8 @@ class Module(bumblebee.engine.Module):
|
||||||
result.append(str(widget.get(t, 0)))
|
result.append(str(widget.get(t, 0)))
|
||||||
return '/'.join(result)
|
return '/'.join(result)
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self):
|
||||||
thread = threading.Thread(target=get_dnf_info, args=(widgets[0],))
|
thread = threading.Thread(target=get_dnf_info, args=(self.widget(),))
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
|
|
Loading…
Reference in a new issue