-
-
Save Yofel/2162326 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/env python | |
import sys, re, subprocess, argparse, urllib2, StringIO, gzip | |
from itertools import islice | |
from optparse import OptionParser | |
from launchpadlib.launchpad import Launchpad | |
def get_http_gzip(url): | |
f = urllib2.urlopen(url) | |
compresseddata = f.read() | |
compressedstream = StringIO.StringIO(compresseddata) | |
gzipper = gzip.GzipFile(fileobj=compressedstream) | |
return gzipper.read() | |
parser = OptionParser("%prog ppa:<owner>/<ppa>") | |
(options, args) = parser.parse_args() | |
lp = Launchpad.login_anonymously("kubuntu-parse-build-log", "production") | |
ubuntu = lp.distributions["ubuntu"] | |
#series = ubuntu.current_series | |
series = ubuntu.getSeries(name_or_version="quantal") | |
if len(args) < 1: | |
parser.error('No ppa given!') | |
ppa = args[0] | |
if not ppa.find(':') > 0 or not ppa.find('/') > 0: | |
parser.error('Invalid ppa syntax [%s], needs to be in ppa:<owner>/<ppa> form.' % ppa) | |
owner = ppa[ppa.find(':') + 1:ppa.find('/')] | |
PPA = ppa[ppa.find('/') + 1:] | |
lp_PPA = lp.people[owner].getPPAByName(name=PPA) | |
for source in lp_PPA.getPublishedSources(distro_series=series, status='Published'): | |
print('Now inspecting %s' % source.source_package_name) | |
build = source.getBuilds()[0] | |
try: | |
buff = get_http_gzip(build.build_log_url) | |
except AttributeError: | |
# Buildlog can't be opened, so ignore it | |
# Happens at least for pending and in progress builds | |
# TODO: try to fetch an older log? | |
print("Can't open buildlog") | |
continue | |
if (re.search("Configuring done", buff) != None): | |
if re.findall("Congratulations! All external packages have been found.", buff, re.DOTALL) and not re.findall("Could NOT find", buff, re.DOTALL): | |
print("Everything found OK") | |
elif re.findall("The following OPTIONAL packages could NOT be located on your system.", buff, re.DOTALL): | |
cut = re.findall("-- The following OPTIONAL packages.*Configuring done", buff, re.DOTALL)[0] | |
print("Couldn't find:") | |
print('\n'.join(re.findall("\* [^\n]*", cut))) | |
elif re.findall("Could NOT find", buff, re.DOTALL): | |
# cmake package, but without summary | |
print('\n'.join(re.findall("Could NOT find.*", buff))) | |
# FIXME: these can be seen even in packages where the summary says | |
# everything is found - pkg-config? | |
else: | |
print("Everything found OK") # probably? | |
else: | |
ret = re.findall("CMake .*-- Configuring[^\n]*", buff, re.DOTALL) | |
if ret: | |
# some Error happened, dump the full log starting from the Error | |
print ret[0] | |
else: | |
# If we end up here we have no log from cmake for whatever reason | |
print("No cmake log found!") | |
print("All Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment