From nobody Fri Mar 29 14:14:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49682+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49682+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572479309; cv=none; d=zoho.com; s=zohoarc; b=oRDEL/LeOmBuV7fCB67f+67OyOdbfTtGQBPjmWqpeGnuNfy/P3M//Wd7DuxZtXcha3RaO5aLK1j4CmK3PchG0EIq1OEcjaSeY4z1ikNTNVESDyC7Kx45OeAfsFBh6LFRwEMhoQptkMHcm9TPI4iZZ3FIb5jxxFIpZN46UiR9PeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572479309; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=w2HQ8iugDfTYT4UqVGIjahcmI61CZziLVTGOsgUmsIM=; b=O30dOTStZ6GVwOKWD8mxoqdzQT58gk3YqOXRDp3AuI7nPZ5VE/A4MCnxtFvTWjOqfLLajQhBy7AWoco8KhNgtvvkTCJQ6ojHQNSaD+VMXvNFbHOyGj78AoKDxp61cI2MEDrxG9PNVGdOv0c6thNg2warw5xva1V8XS0eA5gRdTA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49682+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1572479309783252.86244175745082; Wed, 30 Oct 2019 16:48:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0fC3YY1788612xCg2nrHswXi; Wed, 30 Oct 2019 16:48:29 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.277.1572479308546502163 for ; Wed, 30 Oct 2019 16:48:28 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2019 16:48:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,248,1569308400"; d="scan'208";a="283708680" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.63]) by orsmga001.jf.intel.com with ESMTP; 30 Oct 2019 16:48:27 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Ashley E Desimone , Puja Pandya Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Python 2.x deprecation warning in pip breaks EdkRepoInstaller Date: Wed, 30 Oct 2019 16:48:15 -0700 Message-Id: <20191030234815.4506-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,nathaniel.l.desimone@intel.com X-Gm-Message-State: Hmw9RNJqtmf4qfCCosbRghogx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1572479309; bh=ej46dfxJFrt19BlAq5Hvr+bDTFLnkPR94qNc2EMOkVg=; h=Cc:Date:From:Reply-To:Subject:To; b=SaUN7oYrOUVL2CxZcfJmAIqmKOEjoLyZeVhrgCTS35h872fwQ2o9jprxcqvz/mnK2w0 opM5WgGhEN0CIvlV+RIyCMLHofkosqkgM+zKFLXmvAVMSxzpITrVmsTi6l/+3m6GYmVJ6 A4At70nqqubaWpqejM25MKcdMypryfvELes= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Newer versions of pip add the following output in addition to the JSON output when running on Python 2.7: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. This breaks machine parsing of the JSON output from pip. Adding logic to strip the deprecation warning to fix this issue. Signed-off-by: Nate DeSimone Cc: Ashley E Desimone Cc: Puja Pandya Reviewed-by: Ashley DeSimone --- .../EdkRepoInstaller/PythonOperations.cs | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/edkrepo_installer/EdkRepoInstaller/PythonOperations.cs b/edkre= po_installer/EdkRepoInstaller/PythonOperations.cs index f96502c..73d5bec 100644 --- a/edkrepo_installer/EdkRepoInstaller/PythonOperations.cs +++ b/edkrepo_installer/EdkRepoInstaller/PythonOperations.cs @@ -600,17 +600,48 @@ namespace TianoCore.EdkRepoInstaller return PythonPackages; } =20 + private static string SanitizePipOutput(string PipOutput) + { + StringBuilder Sanitized =3D new StringBuilder(); + IEnumerable PipLines =3D PipOutput.SplitLines(); + foreach(string line in PipLines) + { + if(line.StartsWith("DEPRECATION:")) + { + continue; + } + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + Sanitized.Append(line.Trim()); + Sanitized.Append("\r\n"); + } + return Sanitized.ToString().Trim(); + } + public static List GetInstalledPythonPackages(strin= g PythonPath) { List PythonPackages =3D new List= (); SilentProcess.StdoutDataCapture dataCapture =3D new SilentProc= ess.StdoutDataCapture(); SilentProcess process =3D SilentProcess.StartConsoleProcessSil= ently(PythonPath, "-m pip list --format=3D\"json\" --no-index", dataCapture= .DataReceivedHandler); process.WaitForExit(); + bool TryLegacy =3D true; if (process.ExitCode =3D=3D 0) { - PythonPackages =3D ParseJsonPipList(dataCapture.GetData()); + try + { + PythonPackages =3D ParseJsonPipList(SanitizePipOutput(= dataCapture.GetData())); + TryLegacy =3D false; + } + catch(Exception e) + { + InstallLogger.Log("Error occurred while trying to pars= e pip JSON:"); + InstallLogger.Log(e.ToString()); + InstallLogger.Log("Falling back to legacy mode"); + } } - else + if(TryLegacy) { // // Older versions of pip don't support the --format flag, = parse the legacy format @@ -620,7 +651,7 @@ namespace TianoCore.EdkRepoInstaller process.WaitForExit(); if (process.ExitCode =3D=3D 0) { - PythonPackages =3D ParseLegacyPipList(dataCapture.GetD= ata()); + PythonPackages =3D ParseLegacyPipList(SanitizePipOutpu= t(dataCapture.GetData())); } } return PythonPackages; --=20 2.23.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 (#49682): https://edk2.groups.io/g/devel/message/49682 Mute This Topic: https://groups.io/mt/40038547/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-