2016-11-19 17:44:40 +02:00
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
2017-12-16 01:55:28 +02:00
|
|
|
def parse_config(config, defaults):
|
|
|
|
result = dict()
|
|
|
|
for key in defaults:
|
|
|
|
result[key] = config[key] if key in config else defaults[key]
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2016-11-19 17:44:40 +02:00
|
|
|
class PluginThreadCommon:
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config, defaults=dict()):
|
|
|
|
if 'freq' not in defaults:
|
|
|
|
defaults['freq'] = 1
|
|
|
|
if 'hide_ok' not in defaults:
|
|
|
|
defaults['hide_ok'] = True
|
|
|
|
self.conf = parse_config(config, defaults)
|
2016-11-19 17:44:40 +02:00
|
|
|
self.status = dict()
|
|
|
|
self.hide = False
|
|
|
|
self.thread = threading.Thread(target=self.run)
|
|
|
|
self.thread.daemon = True
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
self.thread.start()
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
self.status['full_text'] = 'placeholder'
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while True:
|
|
|
|
self.main()
|
2017-12-16 01:55:28 +02:00
|
|
|
time.sleep(self.conf['freq'])
|