ubuntutools/lp/lpapicache.py:

* PersonTeam.canUploadPackage() can now also check package sets for upload
  permissions. This requires now to also pass the distroseries as package sets
  are per distroseries.
* Drop PersonTeam.isPerPackageUploader() as it's also handled by canUploadPackage()
ubuntu-build: Update for the PersonTeam.canUploadChange().
ubuntutools/requestsync/{lp,mail}.py:
* needSponsorship() now also expects a release name because of the above mentioned
  change to PersonTeam.canUploadPackage().
requestsync: Update for needSponsorship() change.
This commit is contained in:
Michael Bienia 2010-02-20 15:48:48 +01:00
parent caafd18fb9
commit 0dfe4b4731
5 changed files with 27 additions and 34 deletions

View File

@ -148,7 +148,7 @@ if __name__ == '__main__':
# -s flag not specified - check if we do need sponsorship
if not sponsorship:
sponsorship = needSponsorship(srcpkg, ubuntu_component)
sponsorship = needSponsorship(srcpkg, ubuntu_component, release)
# Check for existing package reports
if not newsource:
@ -183,12 +183,6 @@ if __name__ == '__main__':
if need_interaction:
raw_input_exit_on_ctrlc('Press [Enter] to continue. Press [Ctrl-C] to abort now. ')
# Check if they have a per-package upload permission.
if lpapi:
ubuntu_archive = Distribution('ubuntu').getArchive()
if PersonTeam.getMe().isPerPackageUploader(ubuntu_archive, srcpkg):
report += 'Note that I have per-package upload permissions for %s.\n\n' % srcpkg
base_version = force_base_version or ubuntu_version
if newsource:

View File

@ -132,6 +132,7 @@ if not options.batch:
# Get list of published sources for package in question.
try:
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
distroseries = Distribution('ubuntu').getSeries(release)
except (SeriesNotFoundException, PackageNotFoundException), e:
print e
sys.exit(1)
@ -147,7 +148,7 @@ if not options.batch:
me = PersonTeam.getMe()
if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
if op == "retry": necessaryPrivs = me.canUploadPackage(
ubuntu_archive, sources.getPackageName(), sources.getComponent())
ubuntu_archive, distroseries, sources.getPackageName(), sources.getComponent())
if op in ('rescore', 'retry') and not necessaryPrivs:
print >> sys.stderr, "You cannot perform the %s operation on a %s package " \

View File

@ -414,28 +414,37 @@ class PersonTeam(BaseWrapper):
'''
return any(t.name == team for t in self.super_teams)
def canUploadPackage(self, archive, package, component):
'''
Check if the person or team has upload rights for the source package
to the specified 'archive' either through component upload
rights or per-package upload rights.
def canUploadPackage(self, archive, distroseries, package, component):
'''Check if the person or team has upload rights for the source
package to the specified 'archive' and 'distrorelease' either
through package sets, component or or per-package upload rights.
Either a source package name or a component has the specified.
'archive' has to be a Archive object.
'distroseries' has to be an DistroSeries object.
'''
if not isinstance(archive, Archive):
raise TypeError("'%r' is not an Archive object." % archive)
if package and not isinstance(package, basestring):
if not isinstance(distroseries, DistroSeries):
raise TypeError("'%r' is not a DistroSeries object." % distroseries)
if package is not None and not isinstance(package, basestring):
raise TypeError('A source package name expected.')
if component and not isinstance(component, basestring):
if component is not None and not isinstance(component, basestring):
raise TypeError('A component name expected.')
if not package and not component:
if package is None and component is None:
raise ValueError('Either a source package name or a component has to be specified.')
upload_comp = self._upload_comp.get((archive, component))
upload_pkg = self._upload_pkg.get((archive, package))
if upload_comp == None and upload_pkg == None:
if upload_comp is None and upload_pkg is None:
# archive.isSourceUploadAllowed() checks only package sets permission
if package is not None and archive.isSourceUploadAllowed(
distroseries=distroseries(), person=self(), sourcepackagename=package):
# TODO: also cache the release it applies to
self._upload_pkg[(archive, package)] = True
return True
# check for component or per-package upload rights
for perm in archive.getPermissionsForPerson(person=self()):
if perm.permission != 'Archive Upload Rights':
continue
@ -454,18 +463,6 @@ class PersonTeam(BaseWrapper):
else:
return upload_comp or upload_pkg
# TODO: check if this is still needed after ArchiveReorg (or at all)
def isPerPackageUploader(self, archive, package):
'''
Check if the user has PerPackageUpload rights for package.
'''
if isinstance(package, SourcePackagePublishingHistory):
pkg = package.getPackageName()
else:
pkg = package
return self.canUploadPackage(archive, pkg, None)
class Build(BaseWrapper):
'''

View File

@ -44,14 +44,15 @@ def getUbuntuSrcPkg(name, release):
return ubuntu_archive.getSourcePackage(name, release)
def needSponsorship(name, component):
def needSponsorship(name, component, release):
'''
Check if the user has upload permissions for either the package
itself or the component
'''
archive = Distribution('ubuntu').getArchive()
distroseries = Distribution('ubuntu').getSeries(release)
need_sponsor = not PersonTeam.getMe().canUploadPackage(archive, name, component)
need_sponsor = not PersonTeam.getMe().canUploadPackage(archive, distroseries, 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

View File

@ -118,7 +118,7 @@ def getEmailAddress():
'mail the sync request.'
return myemailaddr
def needSponsorship(name, component):
def needSponsorship(name, component, release):
'''
Ask the user if he has upload permissions for the package or the
component.
@ -126,7 +126,7 @@ def needSponsorship(name, component):
while True:
print "Do you have upload permissions for the '%s' component " \
"or the package '%s'?" % (component, name)
"or the package '%s' in Ubuntu %s?" % (component, name, release)
val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ")
if val.lower() in ('y', 'yes'):
return False