mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-07-03 11:01:31 +00:00
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:
parent
caafd18fb9
commit
0dfe4b4731
@ -148,7 +148,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# -s flag not specified - check if we do need sponsorship
|
# -s flag not specified - check if we do need sponsorship
|
||||||
if not sponsorship:
|
if not sponsorship:
|
||||||
sponsorship = needSponsorship(srcpkg, ubuntu_component)
|
sponsorship = needSponsorship(srcpkg, ubuntu_component, release)
|
||||||
|
|
||||||
# Check for existing package reports
|
# Check for existing package reports
|
||||||
if not newsource:
|
if not newsource:
|
||||||
@ -183,12 +183,6 @@ if __name__ == '__main__':
|
|||||||
if need_interaction:
|
if need_interaction:
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue. Press [Ctrl-C] to abort now. ')
|
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
|
base_version = force_base_version or ubuntu_version
|
||||||
|
|
||||||
if newsource:
|
if newsource:
|
||||||
|
@ -132,6 +132,7 @@ if not options.batch:
|
|||||||
# Get list of published sources for package in question.
|
# Get list of published sources for package in question.
|
||||||
try:
|
try:
|
||||||
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
sources = ubuntu_archive.getSourcePackage(package, release, pocket)
|
||||||
|
distroseries = Distribution('ubuntu').getSeries(release)
|
||||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
except (SeriesNotFoundException, PackageNotFoundException), e:
|
||||||
print e
|
print e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -147,7 +148,7 @@ if not options.batch:
|
|||||||
me = PersonTeam.getMe()
|
me = PersonTeam.getMe()
|
||||||
if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
|
if op == "rescore": necessaryPrivs = me.isLpTeamMember('launchpad-buildd-admins')
|
||||||
if op == "retry": necessaryPrivs = me.canUploadPackage(
|
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:
|
if op in ('rescore', 'retry') and not necessaryPrivs:
|
||||||
print >> sys.stderr, "You cannot perform the %s operation on a %s package " \
|
print >> sys.stderr, "You cannot perform the %s operation on a %s package " \
|
||||||
|
@ -414,29 +414,38 @@ class PersonTeam(BaseWrapper):
|
|||||||
'''
|
'''
|
||||||
return any(t.name == team for t in self.super_teams)
|
return any(t.name == team for t in self.super_teams)
|
||||||
|
|
||||||
def canUploadPackage(self, archive, package, component):
|
def canUploadPackage(self, archive, distroseries, package, component):
|
||||||
'''
|
'''Check if the person or team has upload rights for the source
|
||||||
Check if the person or team has upload rights for the source package
|
package to the specified 'archive' and 'distrorelease' either
|
||||||
to the specified 'archive' either through component upload
|
through package sets, component or or per-package upload rights.
|
||||||
rights or per-package upload rights.
|
|
||||||
Either a source package name or a component has the specified.
|
Either a source package name or a component has the specified.
|
||||||
|
|
||||||
'archive' has to be a Archive object.
|
'archive' has to be a Archive object.
|
||||||
|
'distroseries' has to be an DistroSeries object.
|
||||||
'''
|
'''
|
||||||
if not isinstance(archive, Archive):
|
if not isinstance(archive, Archive):
|
||||||
raise TypeError("'%r' is not an Archive object." % 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.')
|
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.')
|
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.')
|
raise ValueError('Either a source package name or a component has to be specified.')
|
||||||
|
|
||||||
upload_comp = self._upload_comp.get((archive, component))
|
upload_comp = self._upload_comp.get((archive, component))
|
||||||
upload_pkg = self._upload_pkg.get((archive, package))
|
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:
|
||||||
for perm in archive.getPermissionsForPerson(person = self()):
|
# 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':
|
if perm.permission != 'Archive Upload Rights':
|
||||||
continue
|
continue
|
||||||
if component and perm.component_name == component:
|
if component and perm.component_name == component:
|
||||||
@ -454,18 +463,6 @@ class PersonTeam(BaseWrapper):
|
|||||||
else:
|
else:
|
||||||
return upload_comp or upload_pkg
|
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):
|
class Build(BaseWrapper):
|
||||||
'''
|
'''
|
||||||
|
@ -44,14 +44,15 @@ def getUbuntuSrcPkg(name, release):
|
|||||||
|
|
||||||
return ubuntu_archive.getSourcePackage(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
|
Check if the user has upload permissions for either the package
|
||||||
itself or the component
|
itself or the component
|
||||||
'''
|
'''
|
||||||
archive = Distribution('ubuntu').getArchive()
|
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:
|
if need_sponsor:
|
||||||
print '''You are not able to upload this package directly to Ubuntu.
|
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
|
Your sync request shall require an approval by a member of the appropriate
|
||||||
|
@ -118,7 +118,7 @@ def getEmailAddress():
|
|||||||
'mail the sync request.'
|
'mail the sync request.'
|
||||||
return myemailaddr
|
return myemailaddr
|
||||||
|
|
||||||
def needSponsorship(name, component):
|
def needSponsorship(name, component, release):
|
||||||
'''
|
'''
|
||||||
Ask the user if he has upload permissions for the package or the
|
Ask the user if he has upload permissions for the package or the
|
||||||
component.
|
component.
|
||||||
@ -126,7 +126,7 @@ def needSponsorship(name, component):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
print "Do you have upload permissions for the '%s' component " \
|
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]? ")
|
val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ")
|
||||||
if val.lower() in ('y', 'yes'):
|
if val.lower() in ('y', 'yes'):
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user