Skip to content

Commit

Permalink
Ask for gzip'd data from zuul
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Jun 4, 2015
1 parent 26bd34b commit 5f9fed5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dash.py
Expand Up @@ -26,6 +26,8 @@
import urllib
import urllib2
import getpass
import cStringIO
import gzip


IGNORE_QUEUES = ['merge-check', 'silent']
Expand Down Expand Up @@ -82,8 +84,21 @@ def dump_gerrit(auth_creds, filters, operator, projects):

def get_zuul_status():
req = urllib2.Request('http://zuul.openstack.org/status.json')
req.add_header('Accept-encoding', 'gzip')
zuul = urllib2.urlopen(req, timeout=60)
return json.loads(zuul.read())
data = ""
while True:
chunk = zuul.read()
if not chunk:
break
data += chunk

if zuul.info().get('Content-Encoding') == 'gzip':
buf = cStringIO.StringIO(data)
f = gzip.GzipFile(fileobj=buf)
data = f.read()

return json.loads(data)


def dump_zuul():
Expand Down

0 comments on commit 5f9fed5

Please sign in to comment.