tests/docker: handle missing encoding keyword for subprocess.check_output

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
This commit is contained in:
Alex Bennée 2019-09-04 18:46:36 +01:00
parent 71ebbe09e9
commit 884fcafc9c

View File

@ -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: