Created
January 31, 2017 17:44
-
-
Save dims/54b391bd5964d3d208113b16766ea85e to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
import json | |
import sys | |
import time | |
import urllib2 | |
import httplib | |
from collections import deque | |
# Open the URL and the screen name | |
url = "http://zuul.openstack.org/status.json" | |
list = deque(maxlen=100) | |
def fetch(): | |
# This takes a python object and dumps it to a string which is a JSON representation of that object | |
try: | |
data = json.load(urllib2.urlopen(url)) | |
except urllib2.URLError: | |
sys.stdout.write('u') | |
sys.stdout.flush() | |
time.sleep(1) | |
return | |
except httplib.BadStatusLine: | |
sys.stdout.write('b') | |
sys.stdout.flush() | |
time.sleep(1) | |
return | |
except ValueError: | |
sys.stdout.write('v') | |
sys.stdout.flush() | |
time.sleep(1) | |
return | |
for pipeline in data['pipelines']: | |
# print the result | |
if not pipeline['name'] == 'gate': | |
continue | |
for change_queue in pipeline['change_queues']: | |
if not change_queue['name'] == 'integrated': | |
continue | |
for head_list in change_queue['heads']: | |
for head in head_list: | |
for job in head['jobs']: | |
if job['result'] == 'FAILURE': | |
review = "%s %s" % ( | |
head['url'], | |
job['name']) | |
if review in list: | |
continue | |
list.append(review) | |
print("\n>>>> " + time.strftime("%c")) | |
print("\tReview : %s" % head['url']) | |
print("\tURL : %s" % job['url']) | |
print("\t%r" % job) | |
while True: | |
sys.stdout.write('.') | |
sys.stdout.flush() | |
fetch() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment