Merge lp:~geser/ubuntu-archive-tools/anon-login into lp:ubuntu-archive-tools

Proposed by Michael Bienia
Status: Merged
Merged at revision: 182
Proposed branch: lp:~geser/ubuntu-archive-tools/anon-login
Merge into: lp:ubuntu-archive-tools
Diff against target: 83 lines (+12/-5)
1 file modified
edit_acl.py (+12/-5)
To merge this branch: bzr merge lp:~geser/ubuntu-archive-tools/anon-login
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+41633@code.launchpad.net

Description of the change

Add basic support for anonymous LP login for "query" and "check" (most useful to query packageset contents).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'edit_acl.py'
--- edit_acl.py 2010-08-01 22:28:53 +0000
+++ edit_acl.py 2010-11-23 18:07:20 +0000
@@ -12,6 +12,7 @@
12 os.path.dirname(__file__), 'lib'))12 os.path.dirname(__file__), 'lib'))
1313
14import launchpadlib.errors14import launchpadlib.errors
15from launchpadlib.launchpad import Launchpad
1516
16import lputils17import lputils
1718
@@ -83,7 +84,6 @@
8384
84def do_query(options):85def do_query(options):
85 """Query existing permissions and show on stdout."""86 """Query existing permissions and show on stdout."""
86 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
87 if options.archive is None:87 if options.archive is None:
88 archives = launchpad.distributions['ubuntu'].archives88 archives = launchpad.distributions['ubuntu'].archives
89 else:89 else:
@@ -209,7 +209,6 @@
209 if not validate_add_delete_options(options):209 if not validate_add_delete_options(options):
210 return False210 return False
211211
212 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
213 archive = get_archive(options, launchpad)212 archive = get_archive(options, launchpad)
214213
215 if options.packageset and options.source:214 if options.packageset and options.source:
@@ -266,7 +265,6 @@
266 if not validate_add_delete_options(options):265 if not validate_add_delete_options(options):
267 return False266 return False
268267
269 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
270 archive = get_archive(options, launchpad)268 archive = get_archive(options, launchpad)
271269
272 if options.packageset and options.source:270 if options.packageset and options.source:
@@ -323,7 +321,6 @@
323 print "You can only create a package set, not something else."321 print "You can only create a package set, not something else."
324 return False322 return False
325323
326 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
327 if len(options.person) != 1:324 if len(options.person) != 1:
328 print "You must specify exactly one person to own the new package set."325 print "You must specify exactly one person to own the new package set."
329 lp_person = launchpad.people[options.person[0]]326 lp_person = launchpad.people[options.person[0]]
@@ -350,7 +347,6 @@
350 print "A source package needs to be specified to check."347 print "A source package needs to be specified to check."
351 return False348 return False
352349
353 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
354 archive = get_archive(options, launchpad)350 archive = get_archive(options, launchpad)
355 people = [launchpad.people[person] for person in options.person]351 people = [launchpad.people[person] for person in options.person]
356352
@@ -421,6 +417,8 @@
421 parser.add_option("-s", "--source", dest="source", action="append")417 parser.add_option("-s", "--source", dest="source", action="append")
422 parser.add_option("-t", "--acl-type", dest="acl_type",418 parser.add_option("-t", "--acl-type", dest="acl_type",
423 help="ACL type: upload or admin")419 help="ACL type: upload or admin")
420 parser.add_option("--anon", dest="anon_login", action="store_true",
421 default=False, help="Login anonymously to Launchpad")
424422
425 options, args = parser.parse_args()423 options, args = parser.parse_args()
426424
@@ -431,6 +429,10 @@
431 "You must specify an action, one of:\n%s"429 "You must specify an action, one of:\n%s"
432 % ", ".join(possible_actions))430 % ", ".join(possible_actions))
433431
432 if options.anon_login and args[0] not in ('query', 'check'):
433 print "E: Anonymous login not supported for this action."
434 sys.exit(1)
435
434 if (not options.person and not options.component and436 if (not options.person and not options.component and
435 not options.packageset and not options.source):437 not options.packageset and not options.source):
436 parser.error("Provide at least one of "438 parser.error("Provide at least one of "
@@ -445,6 +447,11 @@
445 if options.acl_type == 'admin' and options.source:447 if options.acl_type == 'admin' and options.source:
446 parser.error("ACL type admin not allowed for source packages")448 parser.error("ACL type admin not allowed for source packages")
447449
450 if options.anon_login:
451 launchpad = Launchpad.login_anonymously(CONSUMER_KEY, options.launchpad_instance)
452 else:
453 launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
454
448 try:455 try:
449 main(options, args[0])456 main(options, args[0])
450 except launchpadlib.errors.HTTPError, err:457 except launchpadlib.errors.HTTPError, err:

Subscribers

People subscribed via source and target branches