Commit 15df9d37 authored by Alex Bennée's avatar Alex Bennée
Browse files

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: default avatarAlex Bennée <alex.bennee@linaro.org>
Reviewed-by: default avatarFam Zheng <famz@redhat.com>
parent 1d889f2a
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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]))