From nobody Mon Feb 9 08:29:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+83955+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83955+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1637685082; cv=none; d=zohomail.com; s=zohoarc; b=k/+DJX3zDohadgmSrVaWiiOQaZzmXfy9sTqFYJuakxGXAEXlOnB5v4+e3P3iPUdk5aimK0S8bWxjZqswQfVCm18EDwWWcPz6JadhLxW41/jVPPoOAfNttq9ghq7hnbgMeiIDmveg6l7eaYRLKTSn71LwNYHzeEBzDfW3+GUV2aY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637685082; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=szeMzu/XspkJZMYJQtKxxPkXG9sxM7onZGtFi2gBjhA=; b=DXjNNahootbNQ6awAW7wjNemzZXRLM1i65BbvR6C6J1Vh33SMuJqmPmFqMQeEXYj+wHXnY5fqQtGNLmMEsOtE3QJR7/ZVZxiSbfOaEpeDZ5LHpru5F3oVufAGkgQU3J8KcfBf7Y0cEu/5q/v2hcvUnqHVEttwPjnH7Qoev1ARhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83955+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637685082530785.4679821705894; Tue, 23 Nov 2021 08:31:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id OuQMYY1788612xAIKcB2rRut; Tue, 23 Nov 2021 08:31:20 -0800 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.13721.1637685075541196235 for ; Tue, 23 Nov 2021 08:31:15 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10176"; a="298466167" X-IronPort-AV: E=Sophos;i="5.87,258,1631602800"; d="scan'208";a="298466167" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2021 08:31:14 -0800 X-IronPort-AV: E=Sophos;i="5.87,258,1631602800"; d="scan'208";a="571112443" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.59.198]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2021 08:31:14 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Liming Gao , Michael Kubacki Subject: [edk2-devel] [Patch V2 2/3] .pytool/Plugin/EccCheck: Remove temp directory on exception Date: Tue, 23 Nov 2021 08:31:00 -0800 Message-Id: <20211123163101.786-3-michael.d.kinney@intel.com> In-Reply-To: <20211123163101.786-1-michael.d.kinney@intel.com> References: <20211123163101.786-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: yLkWPXt5GgUotctY8KUBNMzDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637685080; bh=gwNTpt3ZM5dqeItFT/BmymbP1O9r267OAWe7JMFfF1I=; h=Cc:Date:From:Reply-To:Subject:To; b=DX/cXjyUMoa6A0PXBHV6dg8M8CCblj0b75+6MSJa60SIENlzFzDHgCyx+/cISdsNrUW SCK6hAODwXwnmpEQ78JQSErQP9e+Y3K4VD25HS/sh1BIhT4AHb1jfw6KRHbWoba1zbNdL tj+Zh/QSTaWp6ucjNjk3nW8U91VfiLiwGvo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637685084724100001 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2986 Add try/except to RunBuildPlugin() to remove temporary directory if a KeyboardInterrupt exception or an unexpected exception is detected. Cc: Sean Brogan Cc: Bret Barkelew Cc: Liming Gao Cc: Michael Kubacki Signed-off-by: Michael D Kinney --- .pytool/Plugin/EccCheck/EccCheck.py | 78 +++++++++++++++++------------ 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/.pytool/Plugin/EccCheck/EccCheck.py b/.pytool/Plugin/EccCheck/= EccCheck.py index c4c2af1bf6e4..de766d984f7c 100644 --- a/.pytool/Plugin/EccCheck/EccCheck.py +++ b/.pytool/Plugin/EccCheck/EccCheck.py @@ -72,45 +72,61 @@ class EccCheck(ICiBuildPlugin): =20 # Create temp directory temp_path =3D os.path.join(workspace_path, 'Build', '.pytool', 'Pl= ugin', 'EccCheck') - # Delete temp directory - if os.path.exists(temp_path): - shutil.rmtree(temp_path) - # Copy package being scanned to temp_path - shutil.copytree ( - os.path.join(workspace_path, packagename), - os.path.join(temp_path, packagename), - symlinks=3DTrue - ) - # Copy exception.xml to temp_path - shutil.copyfile ( - os.path.join(basetools_path, "Source", "Python", "Ecc", "excepti= on.xml"), - os.path.join(temp_path, "exception.xml") - ) + try: + # Delete temp directory + if os.path.exists(temp_path): + shutil.rmtree(temp_path) + # Copy package being scanned to temp_path + shutil.copytree ( + os.path.join(workspace_path, packagename), + os.path.join(temp_path, packagename), + symlinks=3DTrue + ) + # Copy exception.xml to temp_path + shutil.copyfile ( + os.path.join(basetools_path, "Source", "Python", "Ecc", "exc= eption.xml"), + os.path.join(temp_path, "exception.xml") + ) =20 - self.ApplyConfig(pkgconfig, temp_path, packagename) - modify_dir_list =3D self.GetModifyDir(packagename) - patch =3D self.GetDiff(packagename) - ecc_diff_range =3D self.GetDiffRange(patch, packagename, temp_path) - # - # Use temp_path as working directory when running ECC tool - # - self.GenerateEccReport(modify_dir_list, ecc_diff_range, temp_path,= basetools_path) - ecc_log =3D os.path.join(temp_path, "Ecc.log") - if self.ECC_PASS: + self.ApplyConfig(pkgconfig, temp_path, packagename) + modify_dir_list =3D self.GetModifyDir(packagename) + patch =3D self.GetDiff(packagename) + ecc_diff_range =3D self.GetDiffRange(patch, packagename, temp_= path) + # + # Use temp_path as working directory when running ECC tool + # + self.GenerateEccReport(modify_dir_list, ecc_diff_range, temp_p= ath, basetools_path) + ecc_log =3D os.path.join(temp_path, "Ecc.log") + if self.ECC_PASS: + # Delete temp directory + if os.path.exists(temp_path): + shutil.rmtree(temp_path) + tc.SetSuccess() + return 0 + else: + with open(ecc_log, encoding=3D'utf8') as output: + ecc_output =3D output.readlines() + for line in ecc_output: + logging.error(line.strip()) + # Delete temp directory + if os.path.exists(temp_path): + shutil.rmtree(temp_path) + tc.SetFailed("EccCheck failed for {0}".format(packagename)= , "CHECK FAILED") + return 1 + except KeyboardInterrupt: + # If EccCheck is interrupted by keybard interrupt, then return= failure # Delete temp directory if os.path.exists(temp_path): shutil.rmtree(temp_path) - tc.SetSuccess() - return 0 + tc.SetFailed("EccCheck interrupted for {0}".format(packagename= ), "CHECK FAILED") + return 1 else: - with open(ecc_log, encoding=3D'utf8') as output: - ecc_output =3D output.readlines() - for line in ecc_output: - logging.error(line.strip()) + # If EccCheck fails for any other exception type, raise the ex= ception # Delete temp directory if os.path.exists(temp_path): shutil.rmtree(temp_path) - tc.SetFailed("EccCheck failed for {0}".format(packagename), "C= HECK FAILED") + tc.SetFailed("EccCheck exception for {0}".format(packagename),= "CHECK FAILED") + raise return 1 =20 def GetDiff(self, pkg: str) -> List[str]: --=20 2.32.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#83955): https://edk2.groups.io/g/devel/message/83955 Mute This Topic: https://groups.io/mt/87262302/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-