
From: Archana Singh <archus@linux.vnet.ibm.com> If command to be run has any non-ascii characters(encoded/unicode value), then the error message might also contain non-ascii characters(encoded/unicode value). If command has encoded value and error has unicode value then combining both into a string result unicode value which will have encoded value result into UnicodeError. For e.g command: u'modinfo -0 \xe1' error: modinfo: ERROR: Module \xc3\xa1 not found. (Note:- It has encoded value of u'\xe1') Combining both into string message: "error: %s returned from cmd: %s"%(error, ' '.join(cmd)) result into UnicodeDecodeError: UnicodeDecodeError('ascii', 'error: modinfo: ERROR: Module \xc3\xa1 not found.\n returned from cmd: ', 30, 31, 'ordinal not in range(128)') Fixed this by converting both to unicode format before combining into message. Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> --- src/wok/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wok/utils.py b/src/wok/utils.py index b37518f..918fd26 100644 --- a/src/wok/utils.py +++ b/src/wok/utils.py @@ -273,7 +273,8 @@ def run_command(cmd, timeout=None, silent=False, tee=None, returncode = proc.returncode if returncode != 0: msg = "rc: %s error: %s returned from cmd: %s" %\ - (returncode, error, ' '.join(cmd)) + (returncode, decode_value(error), + decode_value(' '.join(cmd))) if silent: wok_log.debug(msg) @@ -282,7 +283,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None, wok_log.error(msg) elif error: wok_log.debug("error: %s returned from cmd: %s", - error, ' '.join(cmd)) + decode_value(error), decode_value(' '.join(cmd))) if timeout_flag[0]: msg = ("subprocess is killed by signal.SIGKILL for " -- 2.5.0