From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 01/23] docker: Handle exceptions when looking for docker command
Date: Fri, 23 Sep 2016 13:10:08 +0800 [thread overview]
Message-ID: <1474607430-26500-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1474607430-26500-1-git-send-email-famz@redhat.com>
From: Eduardo Habkost <ehabkost@redhat.com>
When trying to run docker tests on a host without the docker
command, we get the following Python backtrace:
$ make docker-test-quick@centos6 V=1
.../qemu/tests/docker/docker.py build qemu:centos6 .../qemu/tests/docker/dockerfiles/centos6.docker
Traceback (most recent call last):
File ".../qemu/tests/docker/docker.py", line 339, in <module>
sys.exit(main())
File ".../qemu/tests/docker/docker.py", line 336, in main
return args.cmdobj.run(args, argv)
File ".../qemu/tests/docker/docker.py", line 231, in run
dkr = Docker()
File ".../qemu/tests/docker/docker.py", line 98, in __init__
self._command = _guess_docker_command()
File ".../qemu/tests/docker/docker.py", line 41, in _guess_docker_command
stdout=DEVNULL, stderr=DEVNULL) == 0:
File "/usr/lib64/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
.../qemu/tests/docker/Makefile.include:47: recipe for target 'docker-image-centos6' failed
make: *** [docker-image-centos6] Error 1
Change _guess_docker_command() to handle OSError exceptions
raised by subprocess.call(), so we will keep looking for other
commands and print a better error message.
New output will be:
$ make docker-test-quick@centos6 V=1
.../qemu/tests/docker/docker.py build qemu:centos6 .../qemu/tests/docker/dockerfiles/centos6.docker
Traceback (most recent call last):
File ".../qemu/tests/docker/docker.py", line 343, in <module>
sys.exit(main())
File ".../qemu/tests/docker/docker.py", line 340, in main
return args.cmdobj.run(args, argv)
File ".../qemu/tests/docker/docker.py", line 235, in run
dkr = Docker()
File ".../qemu/tests/docker/docker.py", line 102, in __init__
self._command = _guess_docker_command()
File ".../qemu/tests/docker/docker.py", line 49, in _guess_docker_command
commands_txt)
Exception: Cannot find working docker command. Tried:
docker
sudo -n docker
.../qemu/tests/docker/Makefile.include:47: recipe for target 'docker-image-centos6' failed
make: *** [docker-image-centos6] Error 1
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1474369559-16903-1-git-send-email-ehabkost@redhat.com>
[exceptions.OSError -> OSError and drop the import. - Fam]
Signed-off-by: Fam Zheng <famz@redhat.com>
---
tests/docker/docker.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index b85c165..71b0d27 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -37,9 +37,12 @@ def _guess_docker_command():
""" Guess a working docker command or raise exception if not found"""
commands = [["docker"], ["sudo", "-n", "docker"]]
for cmd in commands:
- if subprocess.call(cmd + ["images"],
- stdout=DEVNULL, stderr=DEVNULL) == 0:
- return cmd
+ try:
+ if subprocess.call(cmd + ["images"],
+ stdout=DEVNULL, stderr=DEVNULL) == 0:
+ return cmd
+ except OSError:
+ pass
commands_txt = "\n".join([" " + " ".join(x) for x in commands])
raise Exception("Cannot find working docker command. Tried:\n%s" % \
commands_txt)
--
2.7.4
next prev parent reply other threads:[~2016-09-23 5:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 5:10 [Qemu-devel] [PULL 00/23] Various patches Fam Zheng
2016-09-23 5:10 ` Fam Zheng [this message]
2016-09-23 5:10 ` [Qemu-devel] [PULL 02/23] util: Add UUID API Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 03/23] uuid: Make null_uuid static Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 04/23] vhdx: Use QEMU UUID API Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 05/23] vdi: " Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 06/23] vpc: " Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 07/23] crypto: Switch to " Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 08/23] tests: No longer dependent on CONFIG_UUID Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 09/23] configure: Remove detection code for UUID Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 10/23] vl: Switch qemu_uuid to QemuUUID Fam Zheng
2016-09-27 8:05 ` Christian Borntraeger
2016-09-27 8:13 ` Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 11/23] uuid: Tighten uuid parse Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 12/23] tests: Add uuid tests Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 13/23] Add UUID files to MAINTAINERS Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 14/23] tests: Ignore test-uuid Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 15/23] docker: Generate /packages.txt in centos6 image Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 16/23] docker: Generate /packages.txt in fedora image Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 17/23] docker: Generate /packages.txt in ubuntu image Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 18/23] docker: Update fedora image to latest Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 19/23] docker: Flatten default target list in test-quick Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 20/23] docker: Print used options before doing configure Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 21/23] docker: Support showing environment information Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 22/23] docker: Terminate instances at SIGTERM and SIGHUP Fam Zheng
2016-09-23 5:10 ` [Qemu-devel] [PULL 23/23] docker: exec $CMD Fam Zheng
2016-09-23 13:25 ` [Qemu-devel] [PULL 00/23] Various patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474607430-26500-2-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).