From 8c48beb3b7fabd1e4d9372afaa2f7b2e2a7a6eb5 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Thu, 31 Dec 2020 06:03:21 +0530 Subject: [PATCH] Move daemon.py to background.py and restructure --- background.py | 25 +++++++++++++++++++++++++ daemon.py | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) create mode 100755 background.py delete mode 100755 daemon.py diff --git a/background.py b/background.py new file mode 100755 index 0000000..e670c9e --- /dev/null +++ b/background.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"Background Daemon" +import time +import logging + +from mycroft_bus_client import MessageBusClient + +import config +from daemon import Daemon +from plugins import plugins + +def main(): + "Main function" + logging.basicConfig(level=logging.DEBUG) + mycroft = MessageBusClient() + mycroft.run_in_thread() + daemon = Daemon(config.OSD_URL, config.CAR_API_URL, mycroft) + for plugin in plugins: + daemon.register_plugin(plugin) + while True: + daemon.check_all() + time.sleep(config.DELAY) + +if __name__ == "__main__": + main() diff --git a/daemon.py b/daemon.py deleted file mode 100755 index c3a6dc2..0000000 --- a/daemon.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import time - -import requests - -import config -from plugins import plugins - -def emit(event, data): - json = { - "event": event, - "data": data - } - print(json) - return requests.post(config.OSD_URL, json=json) - -def main(): - data = requests.get(config.CAR_API_URL) - for plugin in plugins: - plugin.check(data.json(), emit) - -if __name__ == "__main__": - while True: - main() - time.sleep(config.DELAY)