Ubuntu Pastebin

Paste from shadeslayer at Thu, 16 Oct 2014 14:26:21 +0000

Download as text
 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
#!/usr/bin/python

import urllib2, tempfile, gzip
import argparse
import time
from launchpadlib.launchpad import Launchpad
launchpad = Launchpad.login_anonymously('ubuntu-dev-tools', 'production')

ubuntu = launchpad.distributions["ubuntu"]
archive = ubuntu.main_archive
series = ubuntu.current_series

parser = argparse.ArgumentParser(description='Grab build logs for a source package')
parser.add_argument('-s', '--series', dest='series',
                    help='Series to grab buildlogs from, if unspecified, \
                          uses current dev',
                    action="store")
parser.add_argument('srcPackage', type=str, help="Source Package name")

args = parser.parse_args()

builds = archive.getPublishedSources(exact_match=True,
                                    source_name=args.srcPackage,
                                    distro_series=series)[0].getBuilds()

for build in builds:
    try:
        http_request = urllib2.urlopen(build.build_log_url)
    except:
        print "Can't fetch URL for arch " + build.arch_tag
    output = tempfile.NamedTemporaryFile(suffix=build.arch_tag + '.log.gz', delete=False)
    print "Fetching build logs for " + args.srcPackage + " arch:" + build.arch_tag
    output.write(http_request.read())
    f = gzip.open(output.name, 'r+b')
    zipd = f.read()
    f_out = open(output.name.replace('.gz', ''), 'w')
    f_out.write(zipd)
    f_out.close()
    output.close()
Download as text