add new util script - bus monitor

allow to watch what's traveling on the messagebus real time
This commit is contained in:
JarbasAI 2021-09-11 03:12:55 -10:00 committed by GitHub
parent f35d0f4977
commit 8c782c1496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#!/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()