Merge lp:~brian-murray/lptools/grab-descriptions into lp:lptools

Proposed by Brian Murray on 2012-05-18
Status: Merged
Approved by: dobey on 2012-05-31
Approved revision: 40
Merged at revision: 42
Proposed branch: lp:~brian-murray/lptools/grab-descriptions
Merge into: lp:lptools
Diff against target: 73 lines (+18/-3)
2 files modified
bin/lp-grab-attachments (+15/-3)
doc/lp-grab-attachments.1 (+3/-0)
To merge this branch: bzr merge lp:~brian-murray/lptools/grab-descriptions
Reviewer Review Type Date Requested Status
dobey (community) 2012-05-18 Approve on 2012-05-31
lptools Hackers 2012-05-18 Pending
Review via email: mp+106469@code.launchpad.net

Commit Message

lp-grab-attachments: add option to download bug descriptions too

Description of the Change

update-manager receives some terrible bug reports where people just copy and paste terminal error messages into the bug description. I thought it'd be useful to download all of the descriptions and search them for a specifc error message so I modified lp-grab-attachments to also grab descriptions.

To post a comment you must log in.
dobey (dobey) :
review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :

There was a problem validating some authors of the branch. Authors must be either one of the listed Launchpad users, or a member of one of the listed teams on Launchpad.

Persons or Teams:

    bdmurray
    contributor-agreement-canonical
    lptools

Unaccepted Authors:

    Brian Murray <email address hidden>

Ubuntu One Auto Pilot (otto-pilot) wrote :

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0, Pending == 0. Got: 1 Approve, 1 Pending.

Ubuntu One Auto Pilot (otto-pilot) wrote :

Voting does not meet specified criteria. Required: Approved >= 1. Got: 1 Approve, 1 Pending.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/lp-grab-attachments'
2--- bin/lp-grab-attachments 2012-02-10 18:41:41 +0000
3+++ bin/lp-grab-attachments 2012-05-18 21:07:21 +0000
4@@ -21,6 +21,7 @@
5 # ##################################################################
6
7 from optparse import OptionParser
8+import codecs
9 import errno
10 import os
11
12@@ -29,7 +30,7 @@
13 USAGE = "lp-grab-attachments <bug numbers>"
14
15
16-def download_attachments(bug):
17+def download_attachments(bug, descriptions):
18
19 bug_folder_name = 'bug-%s' % bug.id
20
21@@ -39,6 +40,14 @@
22 if error.errno == errno.EEXIST:
23 return
24
25+ if descriptions:
26+ description = bug.description
27+ filename = os.path.join(os.getcwd(), bug_folder_name,
28+ 'Description.txt')
29+ local_file = codecs.open(filename, encoding="utf-8", mode="w")
30+ local_file.write(description)
31+ local_file.close()
32+
33 for attachment in bug.attachments:
34 f = attachment.data.open()
35 filename = os.path.join(os.getcwd(), bug_folder_name, f.filename)
36@@ -59,6 +68,9 @@
37 parser.add_option('-P', '--project',
38 help='Download attachments from all bugs with a '
39 'open task for this project')
40+ parser.add_option('-D', '--descriptions', default=False,
41+ action='store_true',
42+ help='Also download bug descriptions as Description.txt')
43
44 opts, args = parser.parse_args()
45 if len(args) < 1 and not opts.package and not opts.project:
46@@ -88,11 +100,11 @@
47 parser.error("'%s' is not a valid bug number." % arg)
48
49 bug = launchpad.bugs[bug_number]
50- download_attachments(bug)
51+ download_attachments(bug, opts.descriptions)
52
53 if opts.duplicates is True:
54 for bug in bug.duplicates:
55- download_attachments(bug)
56+ download_attachments(bug, opts.descriptions)
57
58 if __name__ == '__main__':
59 main()
60
61=== modified file 'doc/lp-grab-attachments.1'
62--- doc/lp-grab-attachments.1 2012-02-10 18:41:41 +0000
63+++ doc/lp-grab-attachments.1 2012-05-18 21:07:21 +0000
64@@ -37,6 +37,9 @@
65 .TP
66 .B \-P \fIPROJECT\fR, \fB\-\-project\fR=\fIPROJECT\fR
67 Download attachments from all bugs with an open task for this project.
68+.TP
69+.BR \-D ", " \-\-descriptions
70+Also download bug descriptions as Description.txt.
71 .SH AUTHOR
72 \fBlp-grab\-attachments\fR was written by Daniel Holbach and this manual page
73 was written by Jonathan Patrick Davies.

Subscribers

People subscribed via source and target branches