diff --git a/lib/cdist/exec/local.py b/lib/cdist/exec/local.py index b346bf7d..521d56c3 100644 --- a/lib/cdist/exec/local.py +++ b/lib/cdist/exec/local.py @@ -93,7 +93,7 @@ class Local(object): assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command self.log.debug("Local run: %s", command) try: - return subprocess.check_output(command, env=env) + return subprocess.check_output(command, env=env).decode() except subprocess.CalledProcessError: raise cdist.Error("Command failed: " + " ".join(command)) except OSError as error: @@ -112,7 +112,7 @@ class Local(object): self.log.debug("Local run script env: %s", env) try: - return subprocess.check_output(command, env=env) + return subprocess.check_output(command, env=env).decode() except subprocess.CalledProcessError as error: script_content = self.run(["cat", script]) self.log.error("Code that raised the error:\n%s", script_content) diff --git a/lib/cdist/exec/remote.py b/lib/cdist/exec/remote.py index 6ec9c46f..7821e993 100644 --- a/lib/cdist/exec/remote.py +++ b/lib/cdist/exec/remote.py @@ -104,7 +104,7 @@ class Remote(object): assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command self.log.debug("Remote run: %s", command) try: - return subprocess.check_output(command, env=env) + return subprocess.check_output(command, env=env).decode() except subprocess.CalledProcessError: raise cdist.Error("Command failed: " + " ".join(command)) except OSError as error: @@ -125,7 +125,7 @@ class Remote(object): self.log.debug("Remote run script env: %s", env) try: - return subprocess.check_output(command, env=env) + return subprocess.check_output(command, env=env).decode() except subprocess.CalledProcessError as error: script_content = self.run(["cat", script]) self.log.error("Code that raised the error:\n%s", script_content) diff --git a/lib/cdist/test/exec/test_local.py b/lib/cdist/test/exec/test_local.py index 40611a0b..b74f412e 100644 --- a/lib/cdist/test/exec/test_local.py +++ b/lib/cdist/test/exec/test_local.py @@ -81,7 +81,7 @@ class LocalTestCase(unittest.TestCase): fd = open(script, "w") fd.writelines(["#!/bin/sh\n", "echo foobar"]) fd.close() - self.assertEqual(self.local.run_script(script), b"foobar\n") + self.assertEqual(self.local.run_script(script), "foobar\n") def test_mkdir(self): temp_dir = self.mkdtemp(dir=self.temp_dir) diff --git a/lib/cdist/test/exec/test_remote.py b/lib/cdist/test/exec/test_remote.py index ae5e7aed..1fdb5833 100644 --- a/lib/cdist/test/exec/test_remote.py +++ b/lib/cdist/test/exec/test_remote.py @@ -76,7 +76,7 @@ class RemoteTestCase(unittest.TestCase): fd = open(script, "w") fd.writelines(["#!/bin/sh\n", "echo foobar"]) fd.close() - self.assertEqual(self.remote.run_script(script), b"foobar\n") + self.assertEqual(self.remote.run_script(script), "foobar\n") def test_mkdir(self): temp_dir = self.mkdtemp(dir=self.temp_dir)