From: Alex Bennée Date: Thu, 10 May 2018 09:45:55 +0000 (+0100) Subject: docker: add "probe" command for configure X-Git-Tag: v3.0.0-rc0~108^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15df9d3783d80f64be3149b9120b6a086bdc210a;p=thirdparty%2Fqemu.git 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 Reviewed-by: Fam Zheng --- diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 1246ba95787..f8267586eb6 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 ..." % os.path.basename(sys.argv[0]))