YAML results don't display correctly as literal strings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
UTAH |
Fix Released
|
Low
|
Javier Collado |
Bug Description
Sometimes the yaml output doesn't display as literal strings the output from commands like in the following fragment:
stderr: "DEBUG: Calling 'ls /tmp/tmpLsm5FK'
\nDEBUG: stderr: \nDEBUG: returncode: 0\nDEBUG: Checking for 'file1' in 'ls' output\n\
DEBUG: Checking for 'file2' in 'ls' output\nDEBUG: Checking for 'file3' in 'ls'\
\ output\nDEBUG: Calling 'ls -l /tmp/tmpLsm5FK/
\ 1 root root 0 Oct 25 13:01 /tmp/tmpLsm5FK/
\ 0\nDEBUG: Calling 'ls -l /tmp/tmpLsm5FK/
\ root root 0 Oct 25 13:01 /tmp/tmpLsm5FK/
\ 0\nDEBUG: Calling 'ls -l /tmp/tmpLsm5FK/
\ root root 0 Oct 25 13:01 /tmp/tmpLsm5FK/
\ 0\n"
Note: this bug is related to: bug1040753
Related branches
- Joe Talbott (community): Approve
-
Diff: 15 lines (+4/-1)1 file modifiedutah/client/result.py (+4/-1)
description: | updated |
description: | updated |
Changed in utah: | |
status: | Triaged → In Progress |
Changed in utah: | |
status: | In Progress → Fix Committed |
status: | Fix Committed → Fix Released |
The problem is that yaml doesn't serialize as literal string those that have whitespace characters before a newline character as in the following example:
>>> import yaml
>>> print yaml.dump('hello world\n', default_style='|')
|
hello world
>>> print yaml.dump('hello world \n', default_style='|')
"hello world \n"
The solution would be to make sure that whitespace is removed, so that the strings are serialized as expected.