Merge lp:~brian-murray/lptools/bug-dupe-props into lp:lptools

Proposed by Brian Murray
Status: Merged
Approved by: dobey
Approved revision: 45
Merged at revision: 43
Proposed branch: lp:~brian-murray/lptools/bug-dupe-props
Merge into: lp:lptools
Diff against target: 128 lines (+124/-0)
1 file modified
bin/lp-bug-dupe-properties (+124/-0)
To merge this branch: bzr merge lp:~brian-murray/lptools/bug-dupe-props
Reviewer Review Type Date Requested Status
dobey Approve
Review via email: mp+108433@code.launchpad.net

Commit message

Add lp-bug-dupe-properties for checking properties of duplicates of a master bug.

Description of the change

I wrote a tool to check the properties of duplicates of a master bug. It's pretty awesome IMHO. ;-)

14:48:59 - flash:[...ptools/lp-bug-dupe-prop/bin] ./lp-bug-dupe-properties --bug 764701 --rtags
LP: #764701 has 36 duplicates
  natty: 765198 765652 768488 769340 769341 770103 771253 775544 784845 800907 820007 820451 836275 840066 840984 843905 861800 873127
  oneiric: 808842 811549 813021 858065 862352 862353 862527 862693 863871 865309 865628 865917 867834 869171 870120 871003 886905 890682

14:56:11 - flash:[...ptools/lp-bug-dupe-prop/bin] ./lp-bug-dupe-properties --bug 991282 --reporter
LP: #991282 has 48 duplicates
  michal-grno: 991209 991210 991211 991212 991214 991215 991216 991218 991230 991265 991269 991271 991275 991278 991279 991280 991281 991283 991284 991285 991286 991288 991289 991291 991292 991294 991295 991296 991297 991298 991299 991300 991301 991302 991303 991304 991306 991307 991309 991320 991325 991337 991343 991350 999258 999260 1004614 1004620

LP: #708517 has 52 duplicates
  2011-02: 725753 725754
  2011-03: 730377 734480 738127 738374 739290 739712 740071 741636 742725 742988 743219 743587 744092 745334 745499 745500 746318
  2011-04: 746976 747359 747465 747711 747795 747858 748117 748712 749015 749156 750151 750662 750957 751476 752222 752233 752848 753094 753188 753438 754707 754798 754834 755314 755315 755411 756366 756423 757799 758034 758175
  2011-05: 778331 780185

Anyway, definitely worth adding.

To post a comment you must log in.
44. By Brian Murray

add in the ability to search the bug description for apport keys

45. By Brian Murray

set key to None if opts.desc is not used

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/lp-bug-dupe-properties'
2--- bin/lp-bug-dupe-properties 1970-01-01 00:00:00 +0000
3+++ bin/lp-bug-dupe-properties 2012-06-05 15:22:30 +0000
4@@ -0,0 +1,124 @@
5+#!/usr/bin/python
6+#
7+# Copyright (C) 2012, Canonical Ltd.
8+# Written by Brian Murray
9+#
10+# ##################################################################
11+#
12+# This program is free software; you can redistribute it and/or
13+# modify it under the terms of the GNU General Public License
14+# as published by the Free Software Foundation; version 3.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# See file /usr/share/common-licenses/GPL-3 for more details.
22+#
23+# ##################################################################
24+
25+from lptools import config
26+from datetime import datetime
27+
28+import argparse
29+import sys
30+
31+release_tags = []
32+
33+def check_duplicate(bug, prop, key):
34+ if prop == 'reporter':
35+ return bug.owner.name
36+ if prop == 'month':
37+ return datetime.strftime(bug.date_created, '%Y-%m')
38+ if prop == 'day':
39+ return datetime.strftime(bug.date_created, '%Y-%m-%d')
40+ if prop == 'tags':
41+ return ' '.join(bug.tags)
42+ if prop == 'rtags':
43+ rtags = set(release_tags).intersection(bug.tags)
44+ return ' '.join(list(rtags))
45+ if prop == 'desc':
46+ APPORT_TAGS = ['apport-crash', 'apport-bug', 'apport-kerneloops', 'apport-package']
47+ if not set(APPORT_TAGS).intersection(bug.tags):
48+ return
49+ description = bug.description
50+ if key not in description:
51+ return
52+ for line in description.splitlines():
53+ if not line.startswith(key):
54+ continue
55+ if key == line.split(': ')[0]:
56+ value = line.split(': ')[-1]
57+ return value
58+
59+
60+def main():
61+ parser = argparse.ArgumentParser(prog='lp-bug-dupe-properties')
62+ group = parser.add_mutually_exclusive_group()
63+ group.add_argument('-r', '--reporter', default=False,
64+ action='store_true', help='Display reporter of duplicates')
65+ group.add_argument('-m', '--month', default=False,
66+ action='store_true', help='Display month duplicates were reported')
67+ group.add_argument('-d', '--day', default=False,
68+ action='store_true', help='Display day duplicates were reported')
69+ group.add_argument('-t', '--tags', default=False,
70+ action='store_true', help='Display tags of duplicates')
71+ group.add_argument('-rt', '--rtags', default=False,
72+ action='store_true', help='Display Ubuntu release tags of duplicates')
73+ group.add_argument('-D', '--desc', default=False, type=str,
74+ help='Search apport bug description for this key e.g. Package')
75+ parser.add_argument('-b', '--bug', type=int,
76+ help='Bug number of which to check the duplicates')
77+
78+ opts = parser.parse_args()
79+ launchpad = config.get_launchpad("bug-dupe-properties")
80+
81+ bug_number = opts.bug
82+ bug = launchpad.bugs[bug_number]
83+
84+ dupe_props = {}
85+
86+ if opts.reporter:
87+ search = 'reporter'
88+ if opts.month:
89+ search = 'month'
90+ if opts.day:
91+ search = 'day'
92+ if opts.tags:
93+ search = 'tags'
94+ if opts.rtags:
95+ search = 'rtags'
96+ ubuntu = launchpad.distributions['ubuntu']
97+ for series in ubuntu.series:
98+ release_tags.append(series.name)
99+ if opts.desc:
100+ search = 'desc'
101+ key = opts.desc
102+ else:
103+ key = None
104+
105+ if bug.number_of_duplicates == 0:
106+ print('LP: #%s has no duplicates!' % bug_number)
107+ sys.exit(1)
108+
109+ for dupe in bug.duplicates:
110+ dupe_num = dupe.id
111+ prop = check_duplicate(dupe, search, key)
112+ if prop in dupe_props.keys():
113+ dupe_props[prop].append(str(dupe_num))
114+ else:
115+ dupe_props[prop] = [str(dupe_num)]
116+
117+ dupe_count = bug.number_of_duplicates
118+ if dupe_count > 1:
119+ print('LP: #%s has %s duplicates' % (bug_number, dupe_count))
120+ elif dupe_count == 1:
121+ print('LP: #%s has %s duplicate' % (bug_number, dupe_count))
122+
123+ for prop, bugs in sorted(dupe_props.items()):
124+ print(' %s: %s' % (prop, ' '.join(bugs)))
125+
126+
127+if __name__ == '__main__':
128+ main()

Subscribers

People subscribed via source and target branches