diff --git a/requestsync b/requestsync index 0c34bf7..b3b51d6 100755 --- a/requestsync +++ b/requestsync @@ -42,32 +42,6 @@ import ubuntutools.common from ubuntutools.requestsync.mail import * from ubuntutools.requestsync.common import * -def checkNeedsSponsorship(srcpkg): - """ - Check that the user has the appropriate permissions by checking what - Launchpad returns when we check if someone can upload a package or not. - - If they are an indirect or direct member of the ~ubuntu-dev team on - Launchpad - sponsorship is not required if the package is in the - universe / multiverse component. - - If they are in the ~ubuntu-core-dev team, no sponsorship required. - """ - if not LpApiWrapper.canUploadPackage(srcpkg): - - print "You are not able to upload this package directly to Ubuntu.\n" \ - "Your sync request shall require an approval by a member of " \ - "the appropriate sponsorship team, who shall be subscribed to " \ - "this bug report.\n" \ - "This must be done before it can be processed by a member of " \ - "the Ubuntu Archive team." - print "If the above is correct please press Enter." - raw_input_exit_on_ctrlc() # Abort if necessary. - return True # Sponsorship required. - - # Is a team member, no sponsorship required. - return False - def checkExistingReports(package): """ Check existing bug reports on Launchpad for a possible sync request. @@ -371,7 +345,7 @@ if __name__ == '__main__': sys.exit(1) # -s flag not specified - check if we do need sponsorship. - if not sponsorship: sponsorship = checkNeedsSponsorship(srcpkg) + if not sponsorship: sponsorship = needSponsorship(srcpkg, component) # Check for existing package reports. if not newsource and use_lp_bugs: checkExistingReports(srcpkg) diff --git a/ubuntutools/requestsync/lp.py b/ubuntutools/requestsync/lp.py index f69080e..541854e 100644 --- a/ubuntutools/requestsync/lp.py +++ b/ubuntutools/requestsync/lp.py @@ -20,7 +20,8 @@ # Please see the /usr/share/common-licenses/GPL-2 file for the full text # of the GNU General Public License license. -from ..lp.lpapiwrapper import Distribution +from .common import raw_input_exit_on_ctrlc +from ..lp.lpapiwrapper import Distribution, PersonTeam from ..lp.udtexceptions import * def getDebianSrcPkg(name, release): @@ -38,3 +39,21 @@ def getUbuntuSrcPkg(name, release): ubuntu_archive = ubuntu.getArchive() return ubuntu_archive.getSourcePackage(name, release) + +def needSponsorship(name, component): + ''' + Check if the user has upload permissions for either the package + itself or the component + ''' + archive = Distribution('ubuntu').getArchive() + + need_sponsor = not PersonTeam.getMe().canUploadPackage(archive, name, component) + if need_sponsor: + print '''You are not able to upload this package directly to Ubuntu. +Your sync request shall require an approval by a member of the appropriate +sponsorship team, who shall be subscribed to this bug report. +This must be done before it can be processed by a member of the Ubuntu Archive +team.''' + raw_input_exit_on_ctrlc('If the above is correct please press [Enter]: ' + + return need_sponsor diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index 1a7a724..fd61eb3 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -22,6 +22,7 @@ import os import sys import subprocess +from .common import raw_input_exit_on_ctrlc from ..lp.udtexceptions import PackageNotFoundException __all__ = ['getDebianSrcPkg', 'getUbuntuSrcPkg'] @@ -93,3 +94,20 @@ def get_email_address(): 'EMAIL needs to be set to let this script mail the ' \ 'sync request.' return myemailaddr + +def needSponsorship(name, component): + ''' + Ask the user if he has upload permissions for the package or the + component. + ''' + + while 1: + print "Do you have upload permissions for the '%s' component " \ + "or the package '%s'?" % (component, name) + val = raw_input_exit_on_ctrlc("If in doubt answer 'no'. [y/N]? ") + if val.lower() in ('y', 'yes'): + return False + elif val.lower() in ('n', 'no', ''): + return True + else: + print 'Invalid answer'