Last active
December 13, 2015 21:48
-
-
Save berg/4979594 to your computer and use it in GitHub Desktop.
Dump an App.net stream to the console. Useful for debugging.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import json | |
import requests | |
endpoint = sys.argv[1] | |
while True: | |
r = requests.get(endpoint, stream=True, timeout=600) | |
for line in r.iter_lines(chunk_size=1): | |
if line: | |
blob = json.loads(line) | |
print '--------', int(time.time()), '->' | |
print json.dumps(blob, sort_keys=True, indent=2) | |
print '' | |
print '' | |
print 'sleeping before reconnect' | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment