#!/usr/bin/python
#
# lp-binary-url -- finds the binary package URL from Launchpad
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See file /usr/share/common-licenses/GPL for more details.
import sys
from launchpadlib.launchpad import Launchpad
if len(sys.argv) < 4:
print ("Usage: %s owner series project arch" % sys.argv[0])
sys.exit(1)
launchpad = Launchpad.login_with('rebuild-livefs', "production",
version="devel")
ubuntu = launchpad.distributions['ubuntu']
archive = ubuntu.main_archive
series = ubuntu.getSeries(name_or_version=sys.argv[2])
owner = launchpad.people[sys.argv[1]]
name = sys.argv[3]
arch = sys.argv[4]
if len(sys.argv) > 5:
ppa_name = sys.argv[5]
archive = owner.getPPAByName(name=ppa_name)
print("Using archive {}".format(archive.reference))
livefs = launchpad.livefses.getByName(name=name, distro_series=series, owner=owner)
print("Requesting ~%s build for %s (%s)" % (owner.name, name, series.name))
arch_series = series.getDistroArchSeries(archtag=arch)
livefs_build = livefs.requestBuild(archive=archive, distro_arch_series=arch_series, pocket="Release")
print ("URL: %s" % livefs_build.web_link)
sys.exit(0)