2016-11-19 17:44:40 +02:00
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
2019-03-28 12:21:15 +02:00
|
|
|
PLUGIN_DEFAULTS = {'freq': 1, 'hide_ok': True}
|
2017-12-16 01:55:28 +02:00
|
|
|
|
|
|
|
|
2016-11-19 17:44:40 +02:00
|
|
|
class PluginThreadCommon:
|
2019-03-28 12:21:15 +02:00
|
|
|
def __init__(self, config, defaults=None):
|
2016-11-19 17:44:40 +02:00
|
|
|
self.status = dict()
|
2019-03-28 12:21:15 +02:00
|
|
|
self.conf = dict()
|
|
|
|
self.conf.update(PLUGIN_DEFAULTS)
|
|
|
|
if defaults:
|
|
|
|
self.conf.update(defaults)
|
|
|
|
self.conf.update(config)
|
2016-11-19 17:44:40 +02:00
|
|
|
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'])
|