2016-11-19 17:44:40 +02:00
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
class PluginThreadCommon:
|
|
|
|
def __init__(self, section, config):
|
|
|
|
self.status = dict()
|
|
|
|
self.hide = False
|
|
|
|
self.thread = threading.Thread(target=self.run)
|
|
|
|
self.thread.daemon = True
|
|
|
|
self.freq = config.getint(section, 'freq', fallback=1)
|
|
|
|
self.problem_value = config.getint(section, 'problem', fallback=70)
|
2017-01-13 13:00:37 +02:00
|
|
|
self.hide_ok = config.getboolean(section, 'hide_ok', fallback=True)
|
2016-11-19 17:44:40 +02:00
|
|
|
if config.has_option(section, 'color'):
|
|
|
|
self.status['color'] = config.get(section, 'color')
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
self.thread.start()
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
self.status['full_text'] = 'placeholder'
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while True:
|
|
|
|
self.main()
|
|
|
|
time.sleep(self.freq)
|