From nobody Mon Apr 29 05:42:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499846215174945.0351376905231; Wed, 12 Jul 2017 00:56:55 -0700 (PDT) Received: from localhost ([::1]:50902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVCVx-0000t3-PY for importer@patchew.org; Wed, 12 Jul 2017 03:56:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVCUm-0000GY-NM for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVCUl-00008p-Tb for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVCUl-00007X-G4 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C18B81227; Wed, 12 Jul 2017 07:55:38 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6F8E1717E; Wed, 12 Jul 2017 07:55:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4C18B81227 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4C18B81227 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 15:55:27 +0800 Message-Id: <20170712075528.22770-2-famz@redhat.com> In-Reply-To: <20170712075528.22770-1-famz@redhat.com> References: <20170712075528.22770-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 07:55:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] docker.py: Drop infile parameter 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The **kwargs can do this just well. Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/docker/docker.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index e707e5b..f5ac86b 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -112,11 +112,9 @@ class Docker(object): signal.signal(signal.SIGTERM, self._kill_instances) signal.signal(signal.SIGHUP, self._kill_instances) =20 - def _do(self, cmd, quiet=3DTrue, infile=3DNone, **kwargs): + def _do(self, cmd, quiet=3DTrue, **kwargs): if quiet: kwargs["stdout"] =3D DEVNULL - if infile: - kwargs["stdin"] =3D infile return subprocess.call(self._command + cmd, **kwargs) =20 def _do_kill_instances(self, only_known, only_active=3DTrue): @@ -184,7 +182,7 @@ class Docker(object): def update_image(self, tag, tarball, quiet=3DTrue): "Update a tagged image using " =20 - self._do(["build", "-t", tag, "-"], quiet=3Dquiet, infile=3Dtarbal= l) + self._do(["build", "-t", tag, "-"], quiet=3Dquiet, stdin=3Dtarball) =20 def image_matches_dockerfile(self, tag, dockerfile): try: --=20 2.9.4 From nobody Mon Apr 29 05:42:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499846331444816.8885679420382; Wed, 12 Jul 2017 00:58:51 -0700 (PDT) Received: from localhost ([::1]:50911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVCXp-0002FX-4d for importer@patchew.org; Wed, 12 Jul 2017 03:58:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVCUq-0000Iu-T0 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVCUp-0000Cb-UA for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVCUp-0000BW-8w for qemu-devel@nongnu.org; Wed, 12 Jul 2017 03:55:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2FAE1C04B31B; Wed, 12 Jul 2017 07:55:42 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06AC01717E; Wed, 12 Jul 2017 07:55:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2FAE1C04B31B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2FAE1C04B31B From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 15:55:28 +0800 Message-Id: <20170712075528.22770-3-famz@redhat.com> In-Reply-To: <20170712075528.22770-1-famz@redhat.com> References: <20170712075528.22770-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Jul 2017 07:55:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] docker.py: Improve subprocess exit code handling 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A few error handlings are missing because we ignore the subprocess exit code, for example "docker build" errors are currently ignored. Introduce _do_check() aside the existing _do() method and use it in a few places. Signed-off-by: Fam Zheng Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/docker/docker.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index f5ac86b..ee40ca0 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -117,6 +117,11 @@ class Docker(object): kwargs["stdout"] =3D DEVNULL return subprocess.call(self._command + cmd, **kwargs) =20 + def _do_check(self, cmd, quiet=3DTrue, **kwargs): + if quiet: + kwargs["stdout"] =3D DEVNULL + return subprocess.check_call(self._command + cmd, **kwargs) + def _do_kill_instances(self, only_known, only_active=3DTrue): cmd =3D ["ps", "-q"] if not only_active: @@ -175,14 +180,14 @@ class Docker(object): extra_files_cksum))) tmp_df.flush() =20 - self._do(["build", "-t", tag, "-f", tmp_df.name] + argv + \ - [docker_dir], - quiet=3Dquiet) + self._do_check(["build", "-t", tag, "-f", tmp_df.name] + argv + \ + [docker_dir], + quiet=3Dquiet) =20 def update_image(self, tag, tarball, quiet=3DTrue): "Update a tagged image using " =20 - self._do(["build", "-t", tag, "-"], quiet=3Dquiet, stdin=3Dtarball) + self._do_check(["build", "-t", tag, "-"], quiet=3Dquiet, stdin=3Dt= arball) =20 def image_matches_dockerfile(self, tag, dockerfile): try: @@ -195,9 +200,9 @@ class Docker(object): label =3D uuid.uuid1().hex if not keep: self._instances.append(label) - ret =3D self._do(["run", "--label", - "com.qemu.instance.uuid=3D" + label] + cmd, - quiet=3Dquiet) + ret =3D self._do_check(["run", "--label", + "com.qemu.instance.uuid=3D" + label] + cmd, + quiet=3Dquiet) if not keep: self._instances.remove(label) return ret --=20 2.9.4