diff options
Diffstat (limited to 'i3/bin/cloogle_stats.py')
-rwxr-xr-x | i3/bin/cloogle_stats.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/i3/bin/cloogle_stats.py b/i3/bin/cloogle_stats.py index 6bdc0b8..a572207 100755 --- a/i3/bin/cloogle_stats.py +++ b/i3/bin/cloogle_stats.py @@ -1,9 +1,14 @@ #!/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'] @@ -19,18 +24,18 @@ def format_query(query): def on_message(ws, msg): try: - print(format_query(json.loads(msg))) + print_and_flush(format_query(json.loads(msg))) except: pass def on_open(ws): - print('Opened connection.') + print_and_flush('Opened connection.') def on_error(ws, err): - print(err) + print_and_flush(err) def on_close(ws): - print('Lost connection.') + print_and_flush('Lost connection.') time.sleep(3) start() |