Browse Source

Unicode characters handling

If script was to produce some non-ascii characters to stdout/stderr
execution plan failed without error message.
This patch fixes unicode handling for those streams
assuming console output is always UTF8/ASCII

Change-Id: Iec9a4b14b3f3d506890b87deb0af66fc196c262d
Closes-Bug: #1398586
(cherry picked from commit 2da000e9b0)
Stan Lagun 4 years ago
parent
commit
82ceba5899

+ 1
- 0
muranoagent/app.py View File

@@ -91,6 +91,7 @@ class MuranoAgent(service.Service):
91 91
                     result, plan)
92 92
                 self._queue.put_execution_result(execution_result, plan)
93 93
             except Exception as ex:
94
+                LOG.exception('Error running execution plan')
94 95
                 execution_result = ex_result.ExecutionResult.from_error(ex,
95 96
                                                                         plan)
96 97
                 self._queue.put_execution_result(execution_result, plan)

+ 1
- 1
muranoagent/execution_result.py View File

@@ -46,7 +46,7 @@ class ExecutionResult(object):
46 46
         if isinstance(error, int):
47 47
             error_code = error
48 48
         elif isinstance(error, Exception):
49
-            message = error.message
49
+            message = unicode(error)
50 50
             if isinstance(error, exc.AgentException):
51 51
                 error_code = error.error_code
52 52
                 additional_info = error.additional_data

+ 9
- 7
muranoagent/executors/application/__init__.py View File

@@ -62,13 +62,15 @@ class ApplicationExecutor(object):
62 62
         stdout, stderr = process.communicate(input)
63 63
         retcode = process.poll()
64 64
         LOG.debug("Script {0} execution finished "
65
-                  "with retcode: '{1}'".format(script_name, str(retcode)))
66
-        if stdout:
67
-            LOG.debug("'{0}' execution stdout: "
68
-                      "'{1}'".format(script_name, stdout))
69
-        if stderr:
70
-            LOG.debug("'{0}' execution stderr: "
71
-                      "'{1}'".format(script_name, stderr))
65
+                  "with retcode: {1}".format(script_name, retcode))
66
+        if stdout is not None:
67
+            stdout = stdout.decode('utf-8')
68
+            LOG.debug(u"'{0}' execution stdout: "
69
+                      u"'{1}'".format(script_name, stdout))
70
+        if stderr is not None:
71
+            stderr = stderr.decode('utf-8')
72
+            LOG.debug(u"'{0}' execution stderr: "
73
+                      u"'{1}'".format(script_name, stderr))
72 74
         result = {
73 75
             'exitCode': retcode,
74 76
             'stdout': stdout.strip() if stdout else None,

Loading…
Cancel
Save