aboutsummaryrefslogtreecommitdiff
path: root/i3/bin
diff options
context:
space:
mode:
authorCamil Staps2017-02-20 23:58:40 +0100
committerCamil Staps2017-02-20 23:58:40 +0100
commitc6103fdee486ae3263fc5b91a4dec31507d7a4bf (patch)
treefce1d995ef200093dba3a6ac53727ddb04904491 /i3/bin
parentReorganise binaries (diff)
Properly restarting cloogle websocket client
Diffstat (limited to 'i3/bin')
-rwxr-xr-xi3/bin/cloogle_stats.py10
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()