Advertisement
Guest User

Untitled

a guest
Aug 12th, 2011
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # Insert into /etc/apt/apt.conf.d/50apt-gentoo:
  4. #
  5. # DPkg {
  6. #         Pre-Install-Pkgs { "/path/to/apt-gentoo || true"; };
  7. # };
  8.  
  9. import time
  10. import random
  11. import urllib2
  12. import fileinput
  13.  
  14. from debian import debfile
  15.  
  16. import sys, StringIO, gzip
  17. from launchpadlib.launchpad import Launchpad
  18.  
  19. launchpad = Launchpad.login_anonymously("apt-gentoo", "production")
  20. ubuntu = launchpad.distributions["ubuntu"]
  21. archive = ubuntu.main_archive
  22.  
  23. def get_build_log_url(sources):
  24.     for source in sources:
  25.         for build in source.getBuilds():
  26.             if (build.arch_tag == pkg_data['Architecture']) and build.build_log_url:
  27.                 return build.build_log_url
  28.  
  29. for filename in fileinput.input():
  30.     pkg_data = debfile.DebFile(filename.strip()).debcontrol()
  31.  
  32.     if 'Source' in pkg_data:
  33.         source_pkg = pkg_data['Source']
  34.     else:
  35.         source_pkg = pkg_data['Package']
  36.  
  37.     sources = archive.getPublishedSources(source_name=source_pkg, version=pkg_data['Version'])
  38.  
  39.     url = get_build_log_url(sources)
  40.     if not url:
  41.         continue
  42.  
  43.     f = urllib2.urlopen(url)
  44.     compresseddata = f.read()
  45.     compressedstream = StringIO.StringIO(compresseddata)
  46.     gzipper = gzip.GzipFile(fileobj=compressedstream)
  47.     log = gzipper.read()
  48.  
  49.     for line in log.splitlines():
  50.         print line
  51.         time.sleep(random.random() * 0.09)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement