summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/tests/unit/utils/test_dovetail_utils.py7
-rw-r--r--dovetail/utils/dovetail_utils.py5
2 files changed, 6 insertions, 6 deletions
diff --git a/dovetail/tests/unit/utils/test_dovetail_utils.py b/dovetail/tests/unit/utils/test_dovetail_utils.py
index 5b403a5c..d912aa84 100644
--- a/dovetail/tests/unit/utils/test_dovetail_utils.py
+++ b/dovetail/tests/unit/utils/test_dovetail_utils.py
@@ -1233,9 +1233,9 @@ class DovetailUtilsTesting(unittest.TestCase):
subp_stdout = Mock()
subprocess_obj.stdout = subp_stdout
subprocess_obj.wait.return_value = 0
- subp_stdout.readline.side_effect = [cmd_output, '']
+ subp_stdout.readline.side_effect = [cmd_output.encode()]
- expected = (0, 'line')
+ expected = (0, "b'line'")
result = dovetail_utils.exec_cmd(
cmd, logger=logger, exit_on_error=True, info=False,
exec_msg_on=True, err_msg='', verbose=verbose,
@@ -1276,7 +1276,7 @@ class DovetailUtilsTesting(unittest.TestCase):
subp_stdout = Mock()
subprocess_obj.stdout = subp_stdout
subprocess_obj.wait.return_value = 1
- subp_stdout.readline.side_effect = [cmd_output, '']
+ subp_stdout.readline.side_effect = [cmd_output.encode()]
dovetail_utils.exec_cmd(
cmd, logger=logger, exit_on_error=True, info=False,
@@ -1286,7 +1286,6 @@ class DovetailUtilsTesting(unittest.TestCase):
log_calls = [
call(verbose, logger, "Executing command: '%s'" % cmd, 'debug'),
call(verbose, logger, cmd_output, 'debug', True),
- call(verbose, logger, '', 'debug', True),
call(verbose, logger, "The command '%s' failed." % cmd, 'error')]
mock_log.assert_has_calls(log_calls)
mock_open.assert_called_once_with(cmd, shell=True, stdout=mock_pipe,
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 9259b03f..306dacd1 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -60,8 +60,9 @@ def exec_cmd(cmd, logger=None, exit_on_error=False, info=False,
count = 1
DEBUG = os.getenv('DEBUG')
for line in iter(p.stdout.readline, b''):
- exec_log(verbose, logger, line.strip(), level, True)
- stdout += line
+ exec_log(verbose, logger, line.strip().decode('unicode-escape'),
+ level, True)
+ stdout += str(line)
if progress_bar and (DEBUG is None or DEBUG.lower() != 'true'):
show_progress_bar(count)
count += 1