blob: 4b21d132c1f83539e976a6fdc7cd2e5e0076000c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/python
import blessings
import HTMLParser
import requests
import sys
BASE='https://build.gluster.org'
TERM=blessings.Terminal()
class FailureFinder (HTMLParser.HTMLParser):
def __init__ (*args):
apply(HTMLParser.HTMLParser.__init__,args)
self = args[0]
self.last_href = None
def handle_starttag (self, tag, attrs):
if tag == 'a':
return self.is_a_tag (attrs)
if tag == 'img':
return self.is_img_tag (attrs)
def is_a_tag (self, attrs):
attrs_dict = dict(attrs)
try:
if attrs_dict['class'] != 'build-status-link':
return
except KeyError:
return
self.last_href = attrs_dict['href']
def is_img_tag (self, attrs):
if self.last_href == None:
return
attrs_dict = dict(attrs)
try:
if attrs_dict['alt'].find('Failed') == -1:
return
except KeyError:
return
self.process_failure(self.last_href)
self.last_href = None
def process_failure (self, url):
text = requests.get(BASE+url+'Full',verify=False).text
accum = []
for t in text.split('\n'):
if t == 'Result: FAIL':
print TERM.red + ('FAILURE on %s' % BASE+url) + TERM.normal
for t2 in accum:
print t2.encode('utf-8')
accum = []
elif t == 'Result: PASS':
accum = []
else:
accum.append(t)
def main (url):
parser = FailureFinder()
text = requests.get(url,verify=False).text
parser.feed(text)
if len(sys.argv) < 2:
main(BASE+'/job/rackspace-regression-2GB-triggered/')
else:
for u in sys.argv[1:]:
main(BASE+u)
|