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
1=== modified file 'backport.py'
2--- backport.py 2010-05-09 06:18:34 +0000
3+++ backport.py 2010-07-22 10:43:55 +0000
4@@ -12,7 +12,10 @@
5 sys.path.insert(0, os.path.join(
6 os.path.dirname(__file__), 'lib'))
7
8-from debian_bundle import deb822
9+try:
10+ from debian import deb822
11+except ImportError:
12+ from debian_bundle import deb822
13 import apt_pkg
14
15 import lputils
16
17=== modified file 'edit_acl.py'
18--- edit_acl.py 2010-06-29 17:35:11 +0000
19+++ edit_acl.py 2010-07-22 10:43:55 +0000
20@@ -52,7 +52,10 @@
21
22
23 def get_source_components(options, launchpad, archive, source):
24- from debian_bundle import debian_support
25+ try:
26+ from debian import debian_support
27+ except ImportError:
28+ from debian_bundle import debian_support
29
30 args = {}
31 if options.series:
32@@ -337,6 +340,55 @@
33 print ps
34
35
36+def do_check(options):
37+ """Check if a person can upload a package."""
38+ if not options.person:
39+ print "A person needs to be specified to check."
40+ return False
41+ if not options.source:
42+ print "A source package needs to be specified to check."
43+ return False
44+
45+ launchpad = lputils.lpfactory(options.launchpad_instance, CONSUMER_KEY)
46+ archive = get_archive(options, launchpad)
47+ people = [launchpad.people[person] for person in options.person]
48+
49+ if options.series:
50+ distro_series = launchpad.distributions['ubuntu'].getSeries(
51+ name_or_version=options.series)
52+ else:
53+ distro_series = launchpad.distributions['ubuntu'].getDevelopmentSeries()[0]
54+
55+ for person in people:
56+ for srcpkg in options.source:
57+ spph = archive.getPublishedSources(
58+ distro_series=distro_series,
59+ exact_match=True,
60+ pocket='Release',
61+ source_name=srcpkg,
62+ status='Published',
63+ )[0]
64+ try:
65+ archive.checkUpload(
66+ component=spph.component_name,
67+ distroseries=distro_series,
68+ person=person,
69+ pocket='Release',
70+ sourcepackagename=srcpkg,
71+ )
72+ print "%s (%s) can upload %s to %s" % (
73+ person.display_name, person.name,
74+ srcpkg, distro_series.displayname)
75+ except launchpadlib.errors.HTTPError, e:
76+ if e.response.status == 403:
77+ print "%s (%s) cannot upload %s to %s" % (
78+ person.display_name, person.name,
79+ srcpkg, distro_series.displayname)
80+ else:
81+ print "There was a %s error:" % e.response.status
82+ print e.content
83+
84+
85 def main(options, action):
86
87 if action == "query":
88@@ -347,6 +399,8 @@
89 do_delete(options)
90 elif action == "create":
91 do_create(options)
92+ elif action == "check":
93+ do_check(options)
94 else:
95 raise AssertionError("Invalid action %s" % action)
96
97@@ -354,7 +408,7 @@
98
99
100 if __name__ == '__main__':
101- parser = OptionParser(usage="usage: %prog [options] query|add|delete|create")
102+ parser = OptionParser(usage="usage: %prog [options] query|add|delete|create|check")
103
104 parser.add_option(
105 "-l", "--launchpad", dest="launchpad_instance", default="edge")
106@@ -369,7 +423,7 @@
107
108 options, args = parser.parse_args()
109
110- possible_actions = ('query', 'add', 'delete', 'create')
111+ possible_actions = ('query', 'add', 'delete', 'create', 'check')
112
113 if len(args) != 1:
114 parser.error(
115@@ -393,5 +447,5 @@
116 try:
117 main(options, args[0])
118 except launchpadlib.errors.HTTPError, err:
119- print "There was an error:"
120+ print "There was a %s error:" % err.response.status
121 print err.content

Subscribers

People subscribed via source and target branches