[modules/various] Use new interval mechanism
Use generic interval mechanism in most of the modules that use slow updates. Only exception: getcrypto, as the interval is specified in seconds there and I want to retain backwards-compatibility. fixes #220
This commit is contained in:
parent
776be11137
commit
3638aa2420
7 changed files with 55 additions and 79 deletions
|
@ -6,11 +6,10 @@ Requires the following executable:
|
|||
* dnf
|
||||
|
||||
Parameters:
|
||||
* dnf.interval: Time in seconds between two consecutive update checks (defaulst to 1800)
|
||||
* dnf.interval: Time in seconds between two consecutive update checks (defaulst to 30 minutes)
|
||||
|
||||
"""
|
||||
|
||||
import time
|
||||
import threading
|
||||
|
||||
import bumblebee.util
|
||||
|
@ -53,7 +52,7 @@ class Module(bumblebee.engine.Module):
|
|||
def __init__(self, engine, config):
|
||||
widget = bumblebee.output.Widget(full_text=self.updates)
|
||||
super(Module, self).__init__(engine, config, widget)
|
||||
self._next_check = 0
|
||||
self.interval(30)
|
||||
|
||||
def updates(self, widget):
|
||||
result = []
|
||||
|
@ -62,11 +61,8 @@ class Module(bumblebee.engine.Module):
|
|||
return "/".join(result)
|
||||
|
||||
def update(self, widgets):
|
||||
if int(time.time()) < self._next_check:
|
||||
return
|
||||
thread = threading.Thread(target=get_dnf_info, args=(widgets[0],))
|
||||
thread.start()
|
||||
self._next_check = int(time.time()) + self.parameter("interval", 30*60)
|
||||
|
||||
def state(self, widget):
|
||||
cnt = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue