mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2024-12-13 09:27:30 +01:00
Merge pull request #87 from OpenVoiceOS/helper_script/bus-monitor
add new util script - bus monitor
This commit is contained in:
commit
9f1e38a125
33
buildroot-external/rootfs-overlay/usr/bin/bus-monitor
Normal file
33
buildroot-external/rootfs-overlay/usr/bin/bus-monitor
Normal 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()
|
Loading…
Reference in New Issue
Block a user