1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-01-18 20:19:56 +01:00
OpenVoiceOS/buildroot-external/rootfs-overlay/usr/bin/bus-monitor
JarbasAI 8c782c1496
add new util script - bus monitor
allow to watch what's traveling on the messagebus real time
2021-09-11 03:12:55 -10:00

34 lines
777 B
Python

#!/usr/bin/env python3
import traceback
from time import sleep
from mycroft.util.log import LOG
from mycroft.util.time import now_local
from mycroft.messagebus import MessageBusClient
def on_message(message):
dt = str(now_local())[:19]
print(f"{dt} >> {message}")
def main():
sleep(0.5)
# Connect to the default websocket used by mycroft-core
# TODO arg parse
client = MessageBusClient()
client.on("message", on_message)
client.run_forever()
LOG.info('Client stopped.')
if __name__ == '__main__':
# Run loop trying to reconnect if there are any issues starting
# the websocket
while True:
try:
main()
except KeyboardInterrupt:
break
except:
traceback.print_exc()