Merge lp:~bryce/apport/omit_empty into lp:~apport-hackers/apport/trunk

Proposed by Bryce Harrington
Status: Merged
Merged at revision: 1918
Proposed branch: lp:~bryce/apport/omit_empty
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 41 lines (+6/-4)
1 file modified
apport/hookutils.py (+6/-4)
To merge this branch: bzr merge lp:~bryce/apport/omit_empty
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+68616@code.launchpad.net

Description of the change

Fixes a couple typos

Fixes 813798 by adding 'omit_empty' flag to attach_root_command_outputs() so it doesn't append empty fields when a command gives no output.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for the typo fixes!

As for the attach_root_command_outputs() fix, I feel that it would make more sense to just always skip empty keys. Also, I think we should always strip() the result, leading and trailing empty lines have little information (I'm not aware of apport hooks that attach brainfuck source :) ).

So WDYT about this:

   buf = f.read.strip()
   if not buf:
       continue

?

review: Needs Information
Revision history for this message
Bryce Harrington (bryce) wrote :

On Thu, Jul 21, 2011 at 04:32:33AM -0000, Martin Pitt wrote:
> Review: Needs Information
> Thanks for the typo fixes!
>
> As for the attach_root_command_outputs() fix, I feel that it would make more sense to just always skip empty keys. Also, I think we should always strip() the result, leading and trailing empty lines have little information (I'm not aware of apport hooks that attach brainfuck source :) ).
>
> So WDYT about this:
>
> buf = f.read.strip()
> if not buf:
> continue
>
> ?

Yep, that would actually be my preference. Just wasn't sure whether you
wanted to keep the empties for some reason.

Bryce

lp:~bryce/apport/omit_empty updated
1921. By Bryce Harrington

Review by pitti: Just always strip and always skip empties.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apport/hookutils.py'
2--- apport/hookutils.py 2011-07-15 17:23:19 +0000
3+++ apport/hookutils.py 2011-07-21 05:32:26 +0000
4@@ -32,7 +32,7 @@
5 def path_to_key(path):
6 '''Generate a valid report key name from a file path.
7
8- This will meet apport's restrictions on the characters used in keys.
9+ This will replace invalid punctuation symbols with valid ones.
10 '''
11 return path.translate(_path_key_trans)
12
13@@ -54,7 +54,7 @@
14 def read_file(path):
15 '''Return the contents of the specified path.
16
17- Upon error, this will deliver a a text representation of the error,
18+ Upon error, this will deliver a text representation of the error,
19 instead of failing.
20 '''
21 try:
22@@ -83,7 +83,7 @@
23 def attach_dmesg(report):
24 '''Attach information from the kernel ring buffer (dmesg).
25
26- This won't overwite already existing information.
27+ This will not overwrite already existing information.
28 '''
29 try:
30 if not report.get('BootDmesg', '').strip():
31@@ -328,7 +328,9 @@
32 # now read back the individual outputs
33 for keyname in command_map:
34 f = open(os.path.join(workdir, keyname))
35- report[keyname] = f.read()
36+ buf = f.read().strip()
37+ if buf:
38+ report[keyname] = buf
39 f.close()
40 finally:
41 shutil.rmtree(workdir)

Subscribers

People subscribed via source and target branches