websocket client

This commit is contained in:
boyska 2021-10-06 22:11:07 +02:00
parent 20c30d0b05
commit f0a50632ee

29
utils/wsclient.py Executable file
View file

@ -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()