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>
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]))