Fixes #14042
Toshio Kuratomi authored on 2016/01/26 12:17:46... | ... |
@@ -40,6 +40,7 @@ from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError |
40 | 40 |
from ansible.utils.display import Display |
41 | 41 |
from ansible.utils.unicode import to_unicode |
42 | 42 |
|
43 |
+ |
|
43 | 44 |
######################################## |
44 | 45 |
### OUTPUT OF LAST RESORT ### |
45 | 46 |
class LastResort(object): |
... | ... |
@@ -108,7 +109,7 @@ if __name__ == '__main__': |
108 | 108 |
have_cli_options = cli is not None and cli.options is not None |
109 | 109 |
display.error("Unexpected Exception: %s" % to_unicode(e), wrap_text=False) |
110 | 110 |
if not have_cli_options or have_cli_options and cli.options.verbosity > 2: |
111 |
- display.display("the full traceback was:\n\n%s" % traceback.format_exc()) |
|
111 |
+ display.display(u"the full traceback was:\n\n%s" % to_unicode(traceback.format_exc())) |
|
112 | 112 |
else: |
113 | 113 |
display.display("to see the full traceback, use -vvv") |
114 | 114 |
sys.exit(250) |
... | ... |
@@ -48,6 +48,7 @@ from ansible.playbook.task import Task |
48 | 48 |
from ansible.vars.unsafe_proxy import AnsibleJSONUnsafeDecoder |
49 | 49 |
|
50 | 50 |
from ansible.utils.debug import debug |
51 |
+from ansible.utils.unicode import to_unicode |
|
51 | 52 |
|
52 | 53 |
__all__ = ['WorkerProcess'] |
53 | 54 |
|
... | ... |
@@ -135,11 +136,11 @@ class WorkerProcess(multiprocessing.Process): |
135 | 135 |
try: |
136 | 136 |
self._host.vars = dict() |
137 | 137 |
self._host.groups = [] |
138 |
- task_result = TaskResult(self._host, self._task, dict(failed=True, exception=traceback.format_exc(), stdout='')) |
|
138 |
+ task_result = TaskResult(self._host, self._task, dict(failed=True, exception=to_unicode(traceback.format_exc()), stdout='')) |
|
139 | 139 |
self._rslt_q.put(task_result, block=False) |
140 | 140 |
except: |
141 |
- debug("WORKER EXCEPTION: %s" % e) |
|
142 |
- debug("WORKER EXCEPTION: %s" % traceback.format_exc()) |
|
141 |
+ debug(u"WORKER EXCEPTION: %s" % to_unicode(e)) |
|
142 |
+ debug(u"WORKER EXCEPTION: %s" % to_unicode(traceback.format_exc())) |
|
143 | 143 |
|
144 | 144 |
debug("WORKER PROCESS EXITING") |
145 | 145 |
|
... | ... |
@@ -35,6 +35,7 @@ from ansible.plugins import callback_loader, strategy_loader, module_loader |
35 | 35 |
from ansible.template import Templar |
36 | 36 |
from ansible.vars.hostvars import HostVars |
37 | 37 |
from ansible.plugins.callback import CallbackBase |
38 |
+from ansible.utils.unicode import to_unicode |
|
38 | 39 |
|
39 | 40 |
try: |
40 | 41 |
from __main__ import display |
... | ... |
@@ -306,7 +307,7 @@ class TaskQueueManager: |
306 | 306 |
method(*args, **kwargs) |
307 | 307 |
except Exception as e: |
308 | 308 |
import traceback |
309 |
- orig_tb = traceback.format_exc() |
|
309 |
+ orig_tb = to_unicode(traceback.format_exc()) |
|
310 | 310 |
try: |
311 | 311 |
v1_method = method.replace('v2_','') |
312 | 312 |
v1_method(*args, **kwargs) |
... | ... |
@@ -137,20 +137,20 @@ class Connection(ConnectionBase): |
137 | 137 |
protocol.send_message('') |
138 | 138 |
return protocol |
139 | 139 |
except Exception as e: |
140 |
- err_msg = (str(e) or repr(e)).strip() |
|
141 |
- if re.search(r'Operation\s+?timed\s+?out', err_msg, re.I): |
|
140 |
+ err_msg = to_unicode(e).strip() |
|
141 |
+ if re.search(ur'Operation\s+?timed\s+?out', err_msg, re.I): |
|
142 | 142 |
raise AnsibleError('the connection attempt timed out') |
143 |
- m = re.search(r'Code\s+?(\d{3})', err_msg) |
|
143 |
+ m = re.search(ur'Code\s+?(\d{3})', err_msg) |
|
144 | 144 |
if m: |
145 | 145 |
code = int(m.groups()[0]) |
146 | 146 |
if code == 401: |
147 | 147 |
err_msg = 'the username/password specified for this server was incorrect' |
148 | 148 |
elif code == 411: |
149 | 149 |
return protocol |
150 |
- errors.append('%s: %s' % (transport, err_msg)) |
|
151 |
- display.vvvvv('WINRM CONNECTION ERROR: %s\n%s' % (err_msg, traceback.format_exc()), host=self._winrm_host) |
|
150 |
+ errors.append(u'%s: %s' % (transport, err_msg)) |
|
151 |
+ display.vvvvv(u'WINRM CONNECTION ERROR: %s\n%s' % (err_msg, to_unicode(traceback.format_exc())), host=self._winrm_host) |
|
152 | 152 |
if errors: |
153 |
- raise AnsibleError(', '.join(errors)) |
|
153 |
+ raise AnsibleError(', '.join(to_str(errors))) |
|
154 | 154 |
else: |
155 | 155 |
raise AnsibleError('No transport found for WinRM connection') |
156 | 156 |
|