From f0a50632eed39565bba52374ec8fc9db29ffedbf Mon Sep 17 00:00:00 2001 From: boyska Date: Wed, 6 Oct 2021 22:11:07 +0200 Subject: [PATCH] websocket client --- utils/wsclient.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 utils/wsclient.py diff --git a/utils/wsclient.py b/utils/wsclient.py new file mode 100755 index 0000000..59ff065 --- /dev/null +++ b/utils/wsclient.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 -u +import argparse + +import websocket + + +def get_parser(): + p = argparse.ArgumentParser() + p.add_argument( + "--trace", action="store_true", default=False, help="Extra debugging" + ) + p.add_argument("url") + return p + + +def on_message(wsapp, msg): + print(msg) + + +def main(): + args = get_parser().parse_args() + + websocket.enableTrace(args.trace) + wsapp = websocket.WebSocketApp(args.url, on_message=on_message) + wsapp.run_forever() + + +if __name__ == "__main__": + main()