Skip to content

Instantly share code, notes, and snippets.

@Yofel
Forked from shadeslayer/kparselog.py
Created March 22, 2012 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yofel/2162326 to your computer and use it in GitHub Desktop.
Save Yofel/2162326 to your computer and use it in GitHub Desktop.
#!/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")
print
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
print("All Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment