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:

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


People subscribed via source and target branches