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
1=== modified file 'edit_acl.py'
2--- edit_acl.py 2010-08-01 22:28:53 +0000
3+++ edit_acl.py 2010-11-23 18:07:20 +0000
4@@ -12,6 +12,7 @@
5 os.path.dirname(__file__), 'lib'))
6
7 import launchpadlib.errors
8+from launchpadlib.launchpad import Launchpad
9
10 import lputils
11
12@@ -83,7 +84,6 @@
13
14 def do_query(options):
15 """Query existing permissions and show on stdout."""
16- launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
17 if options.archive is None:
18 archives = launchpad.distributions['ubuntu'].archives
19 else:
20@@ -209,7 +209,6 @@
21 if not validate_add_delete_options(options):
22 return False
23
24- launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
25 archive = get_archive(options, launchpad)
26
27 if options.packageset and options.source:
28@@ -266,7 +265,6 @@
29 if not validate_add_delete_options(options):
30 return False
31
32- launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
33 archive = get_archive(options, launchpad)
34
35 if options.packageset and options.source:
36@@ -323,7 +321,6 @@
37 print "You can only create a package set, not something else."
38 return False
39
40- launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
41 if len(options.person) != 1:
42 print "You must specify exactly one person to own the new package set."
43 lp_person = launchpad.people[options.person[0]]
44@@ -350,7 +347,6 @@
45 print "A source package needs to be specified to check."
46 return False
47
48- launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
49 archive = get_archive(options, launchpad)
50 people = [launchpad.people[person] for person in options.person]
51
52@@ -421,6 +417,8 @@
53 parser.add_option("-s", "--source", dest="source", action="append")
54 parser.add_option("-t", "--acl-type", dest="acl_type",
55 help="ACL type: upload or admin")
56+ parser.add_option("--anon", dest="anon_login", action="store_true",
57+ default=False, help="Login anonymously to Launchpad")
58
59 options, args = parser.parse_args()
60
61@@ -431,6 +429,10 @@
62 "You must specify an action, one of:\n%s"
63 % ", ".join(possible_actions))
64
65+ if options.anon_login and args[0] not in ('query', 'check'):
66+ print "E: Anonymous login not supported for this action."
67+ sys.exit(1)
68+
69 if (not options.person and not options.component and
70 not options.packageset and not options.source):
71 parser.error("Provide at least one of "
72@@ -445,6 +447,11 @@
73 if options.acl_type == 'admin' and options.source:
74 parser.error("ACL type admin not allowed for source packages")
75
76+ if options.anon_login:
77+ launchpad = Launchpad.login_anonymously(CONSUMER_KEY, options.launchpad_instance)
78+ else:
79+ launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
80+
81 try:
82 main(options, args[0])
83 except launchpadlib.errors.HTTPError, err:

Subscribers

People subscribed via source and target branches