Merge lp:~geser/ubuntu-archive-tools/add_check_option into lp:ubuntu-archive-tools

Proposed by Michael Bienia
Status: Merged
Merged at revision: 123
Proposed branch: lp:~geser/ubuntu-archive-tools/add_check_option
Merge into: lp:ubuntu-archive-tools
Diff against target: 121 lines (+62/-5)
2 files modified
backport.py (+4/-1)
edit_acl.py (+58/-4)
To merge this branch: bzr merge lp:~geser/ubuntu-archive-tools/add_check_option
Reviewer Review Type Date Requested Status
Ubuntu Package Archive Administrators Pending
Review via email: mp+30632@code.launchpad.net

Description of the change

* 'debian_bundle' got renamed to 'debian'. Try importing it first before falling back to the old name.
* Also display the HTTP error code
* Add an option to edit_acl.py to check if a person has upload permissions for a package.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'backport.py'
--- backport.py 2010-05-09 06:18:34 +0000
+++ backport.py 2010-07-22 10:43:55 +0000
@@ -12,7 +12,10 @@
12sys.path.insert(0, os.path.join(12sys.path.insert(0, os.path.join(
13 os.path.dirname(__file__), 'lib'))13 os.path.dirname(__file__), 'lib'))
1414
15from debian_bundle import deb82215try:
16 from debian import deb822
17except ImportError:
18 from debian_bundle import deb822
16import apt_pkg19import apt_pkg
1720
18import lputils21import lputils
1922
=== modified file 'edit_acl.py'
--- edit_acl.py 2010-06-29 17:35:11 +0000
+++ edit_acl.py 2010-07-22 10:43:55 +0000
@@ -52,7 +52,10 @@
5252
5353
54def get_source_components(options, launchpad, archive, source):54def get_source_components(options, launchpad, archive, source):
55 from debian_bundle import debian_support55 try:
56 from debian import debian_support
57 except ImportError:
58 from debian_bundle import debian_support
5659
57 args = {}60 args = {}
58 if options.series:61 if options.series:
@@ -337,6 +340,55 @@
337 print ps340 print ps
338341
339342
343def do_check(options):
344 """Check if a person can upload a package."""
345 if not options.person:
346 print "A person needs to be specified to check."
347 return False
348 if not options.source:
349 print "A source package needs to be specified to check."
350 return False
351
352 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
353 archive = get_archive(options, launchpad)
354 people = [launchpad.people[person] for person in options.person]
355
356 if options.series:
357 distro_series = launchpad.distributions['ubuntu'].getSeries(
358 name_or_version=options.series)
359 else:
360 distro_series = launchpad.distributions['ubuntu'].getDevelopmentSeries()[0]
361
362 for person in people:
363 for srcpkg in options.source:
364 spph = archive.getPublishedSources(
365 distro_series=distro_series,
366 exact_match=True,
367 pocket='Release',
368 source_name=srcpkg,
369 status='Published',
370 )[0]
371 try:
372 archive.checkUpload(
373 component=spph.component_name,
374 distroseries=distro_series,
375 person=person,
376 pocket='Release',
377 sourcepackagename=srcpkg,
378 )
379 print "%s (%s) can upload %s to %s" % (
380 person.display_name, person.name,
381 srcpkg, distro_series.displayname)
382 except launchpadlib.errors.HTTPError, e:
383 if e.response.status == 403:
384 print "%s (%s) cannot upload %s to %s" % (
385 person.display_name, person.name,
386 srcpkg, distro_series.displayname)
387 else:
388 print "There was a %s error:" % e.response.status
389 print e.content
390
391
340def main(options, action):392def main(options, action):
341393
342 if action == "query":394 if action == "query":
@@ -347,6 +399,8 @@
347 do_delete(options)399 do_delete(options)
348 elif action == "create":400 elif action == "create":
349 do_create(options)401 do_create(options)
402 elif action == "check":
403 do_check(options)
350 else:404 else:
351 raise AssertionError("Invalid action %s" % action)405 raise AssertionError("Invalid action %s" % action)
352406
@@ -354,7 +408,7 @@
354408
355409
356if __name__ == '__main__':410if __name__ == '__main__':
357 parser = OptionParser(usage="usage: %prog [options] query|add|delete|create")411 parser = OptionParser(usage="usage: %prog [options] query|add|delete|create|check")
358412
359 parser.add_option(413 parser.add_option(
360 "-l", "--launchpad", dest="launchpad_instance", default="edge")414 "-l", "--launchpad", dest="launchpad_instance", default="edge")
@@ -369,7 +423,7 @@
369423
370 options, args = parser.parse_args()424 options, args = parser.parse_args()
371425
372 possible_actions = ('query', 'add', 'delete', 'create')426 possible_actions = ('query', 'add', 'delete', 'create', 'check')
373427
374 if len(args) != 1:428 if len(args) != 1:
375 parser.error(429 parser.error(
@@ -393,5 +447,5 @@
393 try:447 try:
394 main(options, args[0])448 main(options, args[0])
395 except launchpadlib.errors.HTTPError, err:449 except launchpadlib.errors.HTTPError, err:
396 print "There was an error:"450 print "There was a %s error:" % err.response.status
397 print err.content451 print err.content

Subscribers

People subscribed via source and target branches