58 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/python
 | 
						|
 | 
						|
from optparse import OptionParser
 | 
						|
import re
 | 
						|
import urlparse
 | 
						|
from launchpadlib.launchpad import Launchpad
 | 
						|
 | 
						|
def create_webroot_url_from_self_link(self_link):
 | 
						|
    scheme, netloc, _, _, _ = urlparse.urlsplit(self_link)
 | 
						|
    netloc = netloc.lstrip("api.")
 | 
						|
    return u"%s://%s/" %(scheme, netloc)
 | 
						|
    
 | 
						|
def get_dsc(archive, package, series):
 | 
						|
    re_version = re.compile(r"^\d+\:")
 | 
						|
   # x = archive.getPublishedSources()
 | 
						|
    x = archive.getPublishedSources(exact_match=True, source_name=package,
 | 
						|
            distro_series=series)
 | 
						|
    webroot = create_webroot_url_from_self_link(archive.self_link)
 | 
						|
   # for i in x:
 | 
						|
    version = x[0].source_package_version
 | 
						|
    version = re_version.sub("", version, 1)
 | 
						|
    #yield "%s~%s/+archive/primary/+files/%s_%s.dsc" \
 | 
						|
    yield "%subuntu/+archive/primary/+files/%s_%s.dsc" \
 | 
						|
         %(webroot, x[0].source_package_name, version)
 | 
						|
         #%(webroot, archive.owner.name, x[0].source_package_name, version)
 | 
						|
 | 
						|
def main():
 | 
						|
    parser = OptionParser(usage="usage: %prog [options] source ...")
 | 
						|
    parser.add_option(
 | 
						|
        "-l", "--launchpad", dest="launchpad_instance", default="production")
 | 
						|
    options, args = parser.parse_args()
 | 
						|
    if not args:
 | 
						|
        parser.error("You must specify at least one soure.")
 | 
						|
 | 
						|
    options.launchpad = Launchpad.login_with(
 | 
						|
        "branch-seeds", options.launchpad_instance)
 | 
						|
 | 
						|
    launchpad = Launchpad.login_anonymously('just testing', 'production')
 | 
						|
    ubuntu = launchpad.distributions["ubuntu"]
 | 
						|
    archive = ubuntu.main_archive
 | 
						|
    series = ubuntu.getSeries(name_or_version="wily")
 | 
						|
 | 
						|
    #distro = options.launchpad.distributions["ubuntu"]
 | 
						|
 | 
						|
    for package in args:
 | 
						|
        #print(package)
 | 
						|
        #print(series)
 | 
						|
        #print(archive)
 | 
						|
 | 
						|
        re_version = re.compile(r"^\d+\:")
 | 
						|
        x = archive.getPublishedSources(exact_match=True, source_name=package, distro_series=series)[0].source_package_version
 | 
						|
 | 
						|
        generator = get_dsc(archive, package, series)
 | 
						|
        for i in generator:
 | 
						|
            print(i)
 | 
						|
 | 
						|
main()
 |