aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2018-05-10 10:45:55 +0100
committerAlex Bennée <alex.bennee@linaro.org>2018-06-05 16:25:42 +0100
commit15df9d3783d80f64be3149b9120b6a086bdc210a (patch)
tree0c64474a4844ad0b5b83de3f69006147f22a027d /tests
parent1d889f2a8baaa265939b339d2f52ec57f5b8a09c (diff)
downloadqemu-15df9d3783d80f64be3149b9120b6a086bdc210a.zip
qemu-15df9d3783d80f64be3149b9120b6a086bdc210a.tar.gz
qemu-15df9d3783d80f64be3149b9120b6a086bdc210a.tar.bz2
docker: add "probe" command for configure
This is a helper function for the configure script. It replies yes, sudo or no to inform the user if non-interactive docker support is available. We trap the Exception to fail gracefully. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/docker/docker.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 1246ba9..f826758 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -390,6 +390,24 @@ class ImagesCommand(SubCommand):
def run(self, args, argv):
return Docker().command("images", argv, args.quiet)
+
+class ProbeCommand(SubCommand):
+ """Probe if we can run docker automatically"""
+ name = "probe"
+
+ def run(self, args, argv):
+ try:
+ docker = Docker()
+ if docker._command[0] == "docker":
+ print "yes"
+ elif docker._command[0] == "sudo":
+ print "sudo"
+ except Exception:
+ print "no"
+
+ return
+
+
def main():
parser = argparse.ArgumentParser(description="A Docker helper",
usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))