Merge ubuntu-archive-tools:unsubscribe-dry-run into ubuntu-archive-tools:main

Proposed by Brian Murray
Status: Merged
Merge reported by: Brian Murray
Merged at revision: 088823ed6cff59dc2497747216fc06e2b4d99901
Proposed branch: ubuntu-archive-tools:unsubscribe-dry-run
Merge into: ubuntu-archive-tools:main
Diff against target: 68 lines (+22/-6)
1 file modified
unsubscribe-team (+22/-6)
Reviewer Review Type Date Requested Status
Utkarsh Gupta (community) Approve
Ubuntu Package Archive Administrators Pending
Review via email: mp+428579@code.launchpad.net

Description of the change

Add a dry-run mode because you have to be a member of the team for the script to work.

Also create a dictionary of teams and packages which a team should not be unsubscribed from e.g. bugs can get filed about the subiquity package and the Foundations team should still check that package for bugs. (It's also useful for the rls- reports.)

To post a comment you must log in.
70474fc... by Brian Murray

Fix a pep8 error

3b3aa67... by Brian Murray

Add chromium-browser as a keeper for desktop-packages

088823e... by Brian Murray

Use a set not a list

Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Nice, this looks good. I haven't ran this myself but seems to do the work. +1 with two trivial points. :)

review: Approve
Revision history for this message
Brian Murray (brian-murray) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/unsubscribe-team b/unsubscribe-team
2index 134f585..24638dd 100755
3--- a/unsubscribe-team
4+++ b/unsubscribe-team
5@@ -9,8 +9,15 @@ import sys
6 from urllib.request import urlopen
7 from package_subscribers import source_names
8
9+# Never unsubscribe a team from a package if it appears here
10+KEEPERS = {'foundations-bugs':
11+ ('subiquity', 'linux-firmware-raspi2'),
12+ 'desktop-packages':
13+ ('chromium-browser')
14+ }
15
16-def unsubscribe(lp, user, ubuntu, current_packages):
17+
18+def unsubscribe(lp, dry_run, user, ubuntu, current_packages):
19 try:
20 lpuser = lp.people[user]
21 except KeyError:
22@@ -23,6 +30,9 @@ def unsubscribe(lp, user, ubuntu, current_packages):
23
24 stale_packages = subscriptions - current_packages
25 for package in stale_packages:
26+ # Don't unsubscribe the team if they want the subscription
27+ if user in KEEPERS and package in KEEPERS[user]:
28+ continue
29 srcpkg = ubuntu.getSourcePackage(name=package)
30 # if the srcpkg has an open MIR bug keep the subscription
31 mir_bug = any([task for task in
32@@ -30,10 +40,13 @@ def unsubscribe(lp, user, ubuntu, current_packages):
33 if "[MIR]" in task.title])
34 if mir_bug:
35 continue
36- print("Unsubscribing from %s" % package)
37- srcpkg = ubuntu.getSourcePackage(name=package)
38- srcpkg.removeBugSubscription(subscriber=lpuser)
39- print('%s is now unsubscribed for all bugs about %s' % (user, package))
40+ if dry_run:
41+ print("Would unsubscribe from %s" % package)
42+ else:
43+ srcpkg = ubuntu.getSourcePackage(name=package)
44+ srcpkg.removeBugSubscription(subscriber=lpuser)
45+ print('%s is now unsubscribed for all bugs about %s' %
46+ (user, package))
47
48
49 def main(argv):
50@@ -47,6 +60,9 @@ def main(argv):
51 help="Select the Launchpad instance to run against. Defaults to "
52 "'production'")
53 parser.add_option(
54+ "-n", "--dry-run", default=False, action="store_true",
55+ help="Only show the subscriptions that would be removed")
56+ parser.add_option(
57 '-q', '--quiet', action='store_true', default=False,
58 help="Quieten progress messages")
59 parser.add_option(
60@@ -75,7 +91,7 @@ def main(argv):
61 current_packages = source_names(options)
62
63 for user in args:
64- unsubscribe(lp, user, ubuntu, current_packages)
65+ unsubscribe(lp, options.dry_run, user, ubuntu, current_packages)
66
67
68 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches