Move daemon.py to background.py and restructure
This commit is contained in:
parent
a349a9f133
commit
8c48beb3b7
25
background.py
Executable file
25
background.py
Executable file
@ -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()
|
25
daemon.py
25
daemon.py
@ -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)
|
|
Loading…
x
Reference in New Issue
Block a user