mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
174 lines
5.8 KiB
Python
Executable File
174 lines
5.8 KiB
Python
Executable File
#!/usr/bin/python3
|
|
#
|
|
# Copyright (C) 2011, Stefano Rivera <stefanor@ubuntu.com>
|
|
#
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
# copyright notice and this permission notice appear in all copies.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
# pylint: disable=invalid-name
|
|
# pylint: enable=invalid-name
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
from ubuntutools import getLogger
|
|
from ubuntutools.lp.lpapicache import (
|
|
Distribution,
|
|
Launchpad,
|
|
PackageNotFoundException,
|
|
Packageset,
|
|
PersonTeam,
|
|
SeriesNotFoundException,
|
|
)
|
|
from ubuntutools.misc import split_release_pocket
|
|
|
|
Logger = getLogger()
|
|
|
|
|
|
def parse_arguments():
|
|
"""Parse arguments and return (options, package)"""
|
|
parser = argparse.ArgumentParser(usage="%(prog)s [options] package")
|
|
parser.add_argument(
|
|
"-r",
|
|
"--release",
|
|
metavar="RELEASE",
|
|
help="Use RELEASE, rather than the current development release",
|
|
)
|
|
parser.add_argument(
|
|
"-a",
|
|
"--list-uploaders",
|
|
action="store_true",
|
|
help="List all the people/teams with upload rights",
|
|
)
|
|
parser.add_argument(
|
|
"-t",
|
|
"--list-team-members",
|
|
action="store_true",
|
|
help="List all team members of teams with upload rights (implies --list-uploaders)",
|
|
)
|
|
parser.add_argument("package", help=argparse.SUPPRESS)
|
|
args = parser.parse_args()
|
|
|
|
if args.list_team_members:
|
|
args.list_uploaders = True
|
|
|
|
return args
|
|
|
|
|
|
def main():
|
|
"""Query upload permissions"""
|
|
args = parse_arguments()
|
|
# Need to be logged in to see uploaders:
|
|
Launchpad.login()
|
|
|
|
ubuntu = Distribution("ubuntu")
|
|
archive = ubuntu.getArchive()
|
|
if args.release is None:
|
|
args.release = ubuntu.getDevelopmentSeries().name
|
|
try:
|
|
release, pocket = split_release_pocket(args.release)
|
|
series = ubuntu.getSeries(release)
|
|
except SeriesNotFoundException as e:
|
|
Logger.error(str(e))
|
|
sys.exit(2)
|
|
|
|
try:
|
|
spph = archive.getSourcePackage(args.package)
|
|
except PackageNotFoundException as e:
|
|
Logger.error(str(e))
|
|
sys.exit(2)
|
|
component = spph.getComponent()
|
|
if args.list_uploaders and (
|
|
pocket != "Release"
|
|
or series.status in ("Experimental", "Active Development", "Pre-release Freeze")
|
|
):
|
|
|
|
component_uploader = archive.getUploadersForComponent(component_name=component)[0]
|
|
Logger.info("All upload permissions for %s:", args.package)
|
|
Logger.info("")
|
|
Logger.info("Component (%s)", component)
|
|
Logger.info("============%s", "=" * len(component))
|
|
print_uploaders([component_uploader], args.list_team_members)
|
|
|
|
packagesets = sorted(
|
|
Packageset.setsIncludingSource(distroseries=series, sourcepackagename=args.package),
|
|
key=lambda p: p.name,
|
|
)
|
|
if packagesets:
|
|
Logger.info("")
|
|
Logger.info("Packagesets")
|
|
Logger.info("===========")
|
|
for packageset in packagesets:
|
|
Logger.info("")
|
|
Logger.info("%s:", packageset.name)
|
|
print_uploaders(
|
|
archive.getUploadersForPackageset(packageset=packageset),
|
|
args.list_team_members,
|
|
)
|
|
|
|
ppu_uploaders = archive.getUploadersForPackage(source_package_name=args.package)
|
|
if ppu_uploaders:
|
|
Logger.info("")
|
|
Logger.info("Per-Package-Uploaders")
|
|
Logger.info("=====================")
|
|
Logger.info("")
|
|
print_uploaders(ppu_uploaders, args.list_team_members)
|
|
Logger.info("")
|
|
|
|
if PersonTeam.me.canUploadPackage(archive, series, args.package, component, pocket):
|
|
Logger.info("You can upload %s to %s.", args.package, args.release)
|
|
else:
|
|
Logger.info("You can not upload %s to %s, yourself.", args.package, args.release)
|
|
if (
|
|
series.status in ("Current Stable Release", "Supported", "Obsolete")
|
|
and pocket == "Release"
|
|
):
|
|
Logger.info(
|
|
"%s is in the '%s' state. You may want to query the %s-proposed pocket.",
|
|
release,
|
|
series.status,
|
|
release,
|
|
)
|
|
else:
|
|
Logger.info(
|
|
"But you can still contribute to it via the sponsorship "
|
|
"process: https://wiki.ubuntu.com/SponsorshipProcess"
|
|
)
|
|
if not args.list_uploaders:
|
|
Logger.info(
|
|
"To see who has the necessary upload rights, "
|
|
"use the --list-uploaders option."
|
|
)
|
|
sys.exit(1)
|
|
|
|
|
|
def print_uploaders(uploaders, expand_teams=False, prefix=""):
|
|
"""Given a list of uploaders, pretty-print them all
|
|
Each line is prefixed with prefix.
|
|
If expand_teams is set, recurse, adding more spaces to prefix on each
|
|
recursion.
|
|
"""
|
|
for uploader in sorted(uploaders, key=lambda p: p.display_name):
|
|
Logger.info(
|
|
"%s* %s (%s)%s",
|
|
prefix,
|
|
uploader.display_name,
|
|
uploader.name,
|
|
" [team]" if uploader.is_team else "",
|
|
)
|
|
if expand_teams and uploader.is_team:
|
|
print_uploaders(uploader.participants, True, prefix=prefix + " ")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|