diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2015-07-07 09:31:00 -0700 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2015-07-07 09:31:00 -0700 |
commit | 314bae2a9e26edb42e57aca6ffb4e9e6e1641351 (patch) | |
tree | 17017bd47c7d0c5432fb783fb341f9e487e3cb11 /lib/ansible/utils/display.py | |
parent | d198b18c1438cb2b92a749b00890edbffaf4d90d (diff) | |
download | ansible-314bae2a9e26edb42e57aca6ffb4e9e6e1641351.tar.gz |
Don't wrap text for AnsibleParserError
This allows not messing up the wonderful error reporting that is
carefully created. Instead of:
$ ansible-playbook foo.yml
[ERROR]: ERROR! 'foo' is not a valid attribute for a Task The error appears
to have been in '/Users/marca/dev/git-repos/ansible/foo.yml': line 4, column 7,
but may be elsewhere in the file depending on the exact syntax problem. The
offending line appears to be: tasks: - name: do something ^ here
we get:
$ ansible-playbook foo.yml
ERROR! 'foo' is not a valid attribute for a Task
The error appears to have been in '/Users/marca/dev/git-repos/ansible/foo.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: do something
^ here
which is much nicer.
Diffstat (limited to 'lib/ansible/utils/display.py')
-rw-r--r-- | lib/ansible/utils/display.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index 6c5e850a70..ab3a06a5ed 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -182,10 +182,13 @@ class Display: (out, err) = cmd.communicate() self.display("%s\n" % out, color=color) - def error(self, msg): - new_msg = "\n[ERROR]: %s" % msg - wrapped = textwrap.wrap(new_msg, 79) - new_msg = "\n".join(wrapped) + "\n" + def error(self, msg, wrap_text=True): + if wrap_text: + new_msg = "\n[ERROR]: %s" % msg + wrapped = textwrap.wrap(new_msg, 79) + new_msg = "\n".join(wrapped) + "\n" + else: + new_msg = msg if new_msg not in self._errors: self.display(new_msg, color='red', stderr=True) self._errors[new_msg] = 1 |