aboutsummaryrefslogtreecommitdiff
path: root/i3/bin/cloogle_stats.py
diff options
context:
space:
mode:
Diffstat (limited to 'i3/bin/cloogle_stats.py')
-rwxr-xr-xi3/bin/cloogle_stats.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/i3/bin/cloogle_stats.py b/i3/bin/cloogle_stats.py
deleted file mode 100755
index a572207..0000000
--- a/i3/bin/cloogle_stats.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python3
-import json
-import ssl
-import sys
-import time
-import websocket
-
-def print_and_flush(s):
- print(s)
- sys.stdout.flush()
-
-def format_query(query):
- if 'className' in query:
- return 'class ' + query['className']
- elif 'typeName' in query:
- return 'type ' + query['typeName']
- elif 'unify' in query:
- if 'name' in query and query['name'] != '':
- return query['name'] + ' :: ' + query['unify']
- else:
- return ':: ' + query['unify']
- else:
- return query['name']
-
-def on_message(ws, msg):
- try:
- print_and_flush(format_query(json.loads(msg)))
- except:
- pass
-
-def on_open(ws):
- print_and_flush('Opened connection.')
-
-def on_error(ws, err):
- print_and_flush(err)
-
-def on_close(ws):
- print_and_flush('Lost connection.')
- time.sleep(3)
- start()
-
-def start():
- ws = websocket.WebSocketApp('wss://cloogle.org:31216',
- subprotocols=['cloogle-stats'],
- on_message=on_message,
- on_open=on_open, on_error=on_error, on_close=on_close)
- ws.run_forever(sslopt={'cert_reqs': ssl.CERT_NONE})
-
-if __name__ == '__main__':
- start()