From nobody Sun Feb 8 12:58:15 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+83926+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+83926+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1637646316; cv=none; d=zohomail.com; s=zohoarc; b=mHWzAPFh2VPrBtbCHMGwaskpqc1Iv3aONXoJUKkRRgvX33nFvkip19O2WG57Ye+/BNIR5SdLHp/fdSfkQF31Svjz+7kJUz0fiL3M/9dhHgPGMba0kzdG2cEiA0NnDRJUzU6TIpOlfzDVO+C0+xzsMSec2xHESqqkVurUchQTmEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637646316; 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=Bk2AoUBJuDeEluylRDpZf9HAezfWsRaeqoaRTfx6WcY=; b=N8ridtB9VIBFfFjCmb6xRPkmjn9SYtWulA6vB7HNo3WWpua4iMCzO+c4JiLNfxJgq0UecwwAzuf3+uHPPfhd9YMhnYgnVsOG3DG4IWw2mM9B9uL/SE56AnL5naiConzgcpKNva9nQCNwqjJxKt3oEF99CSMZvqJSNI/Atx8eeh4= 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+83926+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 1637646316168966.0310055129837; Mon, 22 Nov 2021 21:45:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HzqCYY1788612x2dmMhjIkWU; Mon, 22 Nov 2021 21:45:15 -0800 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.7698.1637646312279977943 for ; Mon, 22 Nov 2021 21:45:12 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10176"; a="234903539" X-IronPort-AV: E=Sophos;i="5.87,256,1631602800"; d="scan'208";a="234903539" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2021 21:45:10 -0800 X-IronPort-AV: E=Sophos;i="5.87,256,1631602800"; d="scan'208";a="674336719" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.191.131]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2021 21:45:10 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Liming Gao , Michael Kubacki Subject: [edk2-devel] [Patch 2/3] .pytool/Plugin/EccCheck: Remove temp directory on exception Date: Mon, 22 Nov 2021 21:44:54 -0800 Message-Id: <20211123054455.600-3-michael.d.kinney@intel.com> In-Reply-To: <20211123054455.600-1-michael.d.kinney@intel.com> References: <20211123054455.600-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: J0q147pzaaCI41X0QcSGUO1Nx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637646315; bh=7/ijlqJ/nd6/ByMnWwsEG4jprFYW/joV6P656w67x7E=; h=Cc:Date:From:Reply-To:Subject:To; b=hmI+6zsHiKfzTv0MWD5sVajYhCAfpgUxzK8uDUQhprdwi8/16xwvqVy+VyhyN1hIMye J6/93Eea1jTks7fqVML4deGnbw7KnrfnvRuZsKrnnOhjLdYmz655bqKP/zlq3SsSzeiTX jBD8jgbV/NzEtatrP+GXMxvwEZ/f9aFL3qQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637646318143100001 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 | 84 +++++++++++++++++------------ 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/.pytool/Plugin/EccCheck/EccCheck.py b/.pytool/Plugin/EccCheck/= EccCheck.py index 82a3f14d6d5c..25583f15bf54 100644 --- a/.pytool/Plugin/EccCheck/EccCheck.py +++ b/.pytool/Plugin/EccCheck/EccCheck.py @@ -72,48 +72,64 @@ class EccCheck(ICiBuildPlugin): =20 # Create temp directory temp_path =3D os.path.join(workspace_path, 'Build', 'ecctemp') - # 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) - # - # Set workingdir to Build output directory because Ecc generates t= emp files - # Can not set workingdir to temp_path because that can be on a dif= ferent - # drive letter for some CI platforms and RunCmd() does not work co= rrectly - # if working dir is on a different drive letter. - # - self.GenerateEccReport(modify_dir_list, ecc_diff_range, temp_path,= basetools_path, os.path.join (workspace_path, 'Build')) - 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) + # + # Set workingdir to Build output directory because Ecc generat= es temp files + # Can not set workingdir to temp_path because that can be on a= different + # drive letter for some CI platforms and RunCmd() does not wor= k correctly + # if working dir is on a different drive letter. + # + self.GenerateEccReport(modify_dir_list, ecc_diff_range, temp_p= ath, basetools_path, os.path.join (workspace_path, 'Build')) + 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 (#83926): https://edk2.groups.io/g/devel/message/83926 Mute This Topic: https://groups.io/mt/87253500/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-