Merge lp:~brian-murray/ubuntu-archive-tools/package-sub-json into lp:ubuntu-archive-tools

Proposed by Brian Murray
Status: Merged
Merged at revision: 918
Proposed branch: lp:~brian-murray/ubuntu-archive-tools/package-sub-json
Merge into: lp:ubuntu-archive-tools
Diff against target: 81 lines (+32/-5)
1 file modified
package-subscribers (+32/-5)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-archive-tools/package-sub-json
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+193321@code.launchpad.net

Description of the change

I've modified unsubscribed-packages to display the subscribers for packages in main and restricted and to write to a json file (although it can still print). Additionally, I renamed it to package-subscribers as it does more than just show the unsubscribed packages.

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

Approved in principle, but I'd like this to dump out information about all packages, as discussed on IRC. I'll make those changes and merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'unsubscribed-packages' => 'package-subscribers'
2--- unsubscribed-packages 2013-08-21 18:24:15 +0000
3+++ package-subscribers 2013-10-30 19:39:18 +0000
4@@ -4,9 +4,11 @@
5
6 import atexit
7 import bz2
8+from collections import defaultdict
9 from contextlib import closing
10 from optparse import OptionParser
11 import shutil
12+import simplejson as json
13 import sys
14 import tempfile
15 try:
16@@ -68,9 +70,17 @@
17 def main():
18 parser = OptionParser(
19 description="Check for source packages in main or restricted in "
20- "active distro series without a team subscribed.")
21+ "active distro series and return a json file of the teams "
22+ "to which they map.")
23 parser.add_option(
24 "-l", "--launchpad", dest="launchpad_instance", default="production")
25+ parser.add_option(
26+ "-u", "--unsubscribed", action="store_true", default=False,
27+ help="Only return packages which have no subscriber")
28+ parser.add_option(
29+ "-p", "--print", action="store_true", default=False,
30+ dest="display",
31+ help="Print results to screen instead of a json file")
32 options, _ = parser.parse_args()
33 options.suite = None
34 options.distribution = "ubuntu"
35@@ -78,6 +88,7 @@
36 "unsubscribed-packages", options.launchpad_instance)
37 launchpad = options.launchpad
38 ubuntu = launchpad.distributions[options.distribution]
39+ json_filename = "m-r-package-team-mapping.json"
40 options.suites = []
41 for series in ubuntu.series:
42 # very few lucid packages are supported
43@@ -110,18 +121,34 @@
44 'xubuntu-bugs',
45 ]
46
47- subscriptions = set()
48+ data = { "unsubscribed": [] }
49+ subscriptions = defaultdict(list)
50 for team_name in team_names:
51+ data[team_name] = []
52 team = launchpad.people[team_name]
53 team_subs = team.getBugSubscriberPackages()
54 for src_pkg in team_subs:
55- subscriptions.add(src_pkg.name)
56+ subscriptions[src_pkg.name].append(team_name)
57
58 source_packages = source_names(options)
59-
60 for source_package in source_packages:
61 if source_package not in subscriptions:
62- print("No team is subscribed to: %s" % source_package)
63+ data["unsubscribed"].append(source_package)
64+ if options.display:
65+ print("No team is subscribed to: %s" %
66+ source_package)
67+ else:
68+ if not options.unsubscribed:
69+ for team_name in subscriptions[source_package]:
70+ data[team_name].append(source_package)
71+ if options.display:
72+ print("%s is subscribed to: %s" %
73+ (team_name, source_package))
74+
75+ if not options.display:
76+ with open(json_filename, 'w') as json_file:
77+ json_file.write(json.dumps(data, indent=4))
78+
79
80 if __name__ == '__main__':
81 main()

Subscribers

People subscribed via source and target branches