diff mbox series

[v1,42/42] tests/docker: don't always encoding for subprocess.check_output

Message ID 20190904203013.9028-43-alex.bennee@linaro.org
State Superseded
Headers show
Series current testing/next queue (podman, docker, ci) | expand

Commit Message

Alex Bennée Sept. 4, 2019, 8:30 p.m. UTC
This was only added in Python 3.6 and not all the build hosts have
that recent a python3. However those that do will complain if
everything isn't properly utf-8 clean:

  ./tests/docker/docker.py --engine auto build qemu:debian-amd64 tests/docker/dockerfiles/debian-amd64.docker   --add-current-user
  Sending build context to Docker daemon  3.584kB

  Step 1/16 : FROM qemu:debian9
  pull access denied for qemu, repository does not exist or may require 'docker login'
  Traceback (most recent call last):
    File "./tests/docker/docker.py", line 659, in <module>
      sys.exit(main())
    File "./tests/docker/docker.py", line 655, in main
      return args.cmdobj.run(args, argv)
    File "./tests/docker/docker.py", line 452, in run
      extra_files_cksum=cksum)
    File "./tests/docker/docker.py", line 306, in build_image
      quiet=quiet)
    File "./tests/docker/docker.py", line 231, in _do_check
      return subprocess.check_call(self._command + cmd, **kwargs)
    File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['docker', 'build', '-t', 'qemu:debian-amd64', '-f', '/tmp/docker_buildjvzs88tf/tmpyvtj7ub0.docker', '/tmp/docker_buildjvzs88tf']' returned non-zero exit status 1
  Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File "./tests/docker/docker.py", line 258, in _kill_instances
      return self._do_kill_instances(True)
    File "./tests/docker/docker.py", line 239, in _do_kill_instances
      labels = json.loads(resp)[0]["Config"]["Labels"]
    File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
      s.__class__.__name__))
  TypeError: the JSON object must be str, not 'bytes'
  make: *** [docker-image-debian-amd64] Error 1

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 tests/docker/docker.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

-- 
2.20.1
diff mbox series

Patch

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 8f391eb278b..e5b7632464b 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -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)
+
 
     def inspect_tag(self, tag):
         try: