From 2f9a12bcb270c5fc00b5ec3cb495155d510b5762 Mon Sep 17 00:00:00 2001 From: Andrew Lazarev Date: Fri, 5 Dec 2014 14:35:36 -0800 Subject: [PATCH] Fixed subprocess error reporting Moved stdout and stderr decoding to earlier stage to prevent decode error. Note, the code is not py3 compatible. But this change doesn't introduce any new incompatibility, it changes order of existing decode calls. Change-Id: I23f7340e254ec249f00c6de9a980adac9e637983 Closes-Bug: #1399490 --- sahara/exceptions.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sahara/exceptions.py b/sahara/exceptions.py index eaec5f0a..28d8c72f 100644 --- a/sahara/exceptions.py +++ b/sahara/exceptions.py @@ -103,12 +103,13 @@ class RemoteCommandException(SaharaException): six.text_type(ret_code)) if stderr: - self.message = '%s\nSTDERR:\n%s' % (self.message, stderr) + self.message = '%s\nSTDERR:\n%s' % ( + self.message, stderr.decode('ascii', 'ignore')) if stdout: - self.message = '%s\nSTDOUT:\n%s' % (self.message, stdout) + self.message = '%s\nSTDOUT:\n%s' % ( + self.message, stdout.decode('ascii', 'ignore')) - self.message = self.message.decode('ascii', 'ignore') super(RemoteCommandException, self).__init__()