diff options
-rwxr-xr-x | i3/bin/cloogle_stats.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/i3/bin/cloogle_stats.py b/i3/bin/cloogle_stats.py index 0c48b70..ad16107 100755 --- a/i3/bin/cloogle_stats.py +++ b/i3/bin/cloogle_stats.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import ssl +import time import websocket def format_query(query): @@ -26,10 +27,15 @@ def on_error(ws, err): print(err) def on_close(ws): - print('Closed.') + print('Lost connection to Cloogle.') + time.sleep(3) + start() -if __name__ == '__main__': +def start(): ws = websocket.WebSocketApp('wss://cloogle.org:31216', subprotocols=['cloogle-stats'], on_message=on_message, on_error=on_error, on_close=on_close) ws.run_forever(sslopt={'cert_reqs': ssl.CERT_NONE}) + +if __name__ == '__main__': + start() |