tests/docker: handle missing encoding keyword for subprocess.check_output
authorAlex Bennée <alex.bennee@linaro.org>
Wed, 4 Sep 2019 17:46:36 +0000 (18:46 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 10 Sep 2019 08:38:33 +0000 (09:38 +0100)
This was only added in Python 3.6 and not all the build hosts have
that recent a python3. However we still need to ensure everything is
returns as a unicode string so checks higher up the call chain don't
barf.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
fixup! tests/docker: handle missing encoding keyword for subprocess.check_output

tests/docker/docker.py

index 1620293ac8483227b155c595a17fd2ee6bacc540..417b0cdce1337f8afba9d83717c7c83ba21dcb40 100755 (executable)
@@ -258,10 +258,16 @@ class Docker(object):
         return self._do_kill_instances(True)
 
     def _output(self, cmd, **kwargs):
-        return subprocess.check_output(self._command + cmd,
-                                       stderr=subprocess.STDOUT,
-                                       encoding='utf-8',
-                                       **kwargs)
+        if sys.version_info[1] >= 6:
+            return subprocess.check_output(self._command + cmd,
+                                           stderr=subprocess.STDOUT,
+                                           encoding='utf-8',
+                                           **kwargs)
+        else:
+            return subprocess.check_output(self._command + cmd,
+                                           stderr=subprocess.STDOUT,
+                                           **kwargs).decode('utf-8')
+
 
     def inspect_tag(self, tag):
         try: