From patchwork Tue Jun 5 16:05:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 137774 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1149006lji; Tue, 5 Jun 2018 09:11:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMkwyAl48Kc3KWxUIS0DIT8ZPmoJRRywospRXEs14z1zSq/GtyWEBouYz61+CCehqHls/z X-Received: by 2002:a0c:c38e:: with SMTP id o14-v6mr16028197qvi.49.1528215084865; Tue, 05 Jun 2018 09:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528215084; cv=none; d=google.com; s=arc-20160816; b=bRVaZ0qoqDOwY9n2S8ymW+rsMqzMQz+Dee9DxlAfTi1miUy89l3iMM24V9H4FV/drf 6Sz4GZAUsP1IYlZPT1j5sRGNYkCr3gWNYXSI6dWk3CryAHWRJV+nxj4aIEj6BTf0WG8X 4/GUa0hMebVQuR1DJY8mDHkSbQnk/fNz1rNkVrH4Rw4fH0FSkVLQiDJbUMogAgzAJEEJ nCzqc3AnZvtabbwE/c7/LkJVWIFk5JKGOQDQPkYp9Fg0PaVC9Yy0oCx+cKqcSpHETLfI 0N87nmH/zGGG2xxr1wNIJz3x48q3QWKgesTpM6nHeIjGnt7F27dpkFJCQSKjjdZiRehY 5DAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=PlTHbx5GnD2XG0NTiiXTWRxIBQvTbySEnV89hR9beM4=; b=gPS2QOBhaoSg5ciPC6O31F30yXbeDq5spIDVUNjoURvTSS9QAv955cU1ELC95LeTBG SrwmffVsSGMhyo1wIG0FsMlfbUATP+wDT3XbEkSDPxTJ98GNMYNoAZrCjO796+NRRjwO QI7WTlL9gDJ1GA0V2WPxjCeN1noX4B+b8buzUEFxxfb6ZJ0uMCaSPJ2mLvrzHun86MwH dp4izJq4eOitQCRC1oLpx7f5M0TW+RTM0ZnLkQLvHYAp69yU3TUqcq3Iwx0B1QmJK4/o cVu4IlucqB2KF6orzl/5C/ulkDyKnff/hJqZycZO/5I8zBxZG0KGntz37nQS5Mz8YgVs HHzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ftAQy5zC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m127-v6si4124596qkc.186.2018.06.05.09.11.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Jun 2018 09:11:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ftAQy5zC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEYO-0002Zo-B8 for patch@linaro.org; Tue, 05 Jun 2018 12:11:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEVH-0000vI-KE for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQESv-0004Jz-1E for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:08:11 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:36039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQESu-0004JE-Lb for qemu-devel@nongnu.org; Tue, 05 Jun 2018 12:05:44 -0400 Received: by mail-wm0-x236.google.com with SMTP id v131-v6so6185897wma.1 for ; Tue, 05 Jun 2018 09:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PlTHbx5GnD2XG0NTiiXTWRxIBQvTbySEnV89hR9beM4=; b=ftAQy5zCeIv/El+yQGMibTDLJmjuDCsoOBD1jBm5CzN3eX4seGm1AJ8mqQXlGHEd1p zoXrXMJXdGBuA8/gzmCUH4iPeG5rpGJ5azY2JWtaQ1ghxnUOpM+tO0atj09DYkN6edaW oJfUUu5yVcWUT5s5HoOov9rkTDvhfiTr9/CJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PlTHbx5GnD2XG0NTiiXTWRxIBQvTbySEnV89hR9beM4=; b=kOv0h2TDVXq6f+c1aDPsq1WUAj4qimRjS9x7HT1oD3Lp63ARzhUEJ+Up5Roy9Gok9T iLgLV3NC20XR9oIDuKboief5HZwt8wSnVCCvNvOl264vnyk8cwi8joe3LWslxbwzh7TX 4/gC3oQsE8KlVPdLCyjhhtT72aiRWdGuyTHf2jefLvHnbOwffOfy0O/JQmWmQDyfsHTQ JdawsXkwvesLlHcYqEU7npZLo/+krMQY0iqEcjp9oRS6TShbFbaNXTqFpLKZPwBJmVmM oHdWG6YHQPLzMM75maBlxThscSoMwVu+uPPAa7V7V+7kB3/+kPsAdqbp1YydiI+fYZC2 /vWw== X-Gm-Message-State: APt69E1+KEfozSnx9IEPMldPdtJekD84O1YlWGbxMb+r6pTE//sHXH6w CkQgpOqJ5vbkXMgcf8owdQ+MPA== X-Received: by 2002:a1c:58ce:: with SMTP id m197-v6mr11633116wmb.110.1528214743568; Tue, 05 Jun 2018 09:05:43 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 203-v6sm2357320wmp.23.2018.06.05.09.05.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 09:05:41 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id AAB613E0971; Tue, 5 Jun 2018 17:05:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 5 Jun 2018 17:05:36 +0100 Message-Id: <20180605160541.10664-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605160541.10664-1-alex.bennee@linaro.org> References: <20180605160541.10664-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [PULL 1/6] docker: add "probe" command for configure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 -- 2.17.0 diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 1246ba9578..f8267586eb 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]))