From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: liming.gao@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Thu, 25 Jul 2019 23:45:03 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2019 23:45:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,309,1559545200"; d="scan'208";a="369443471" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 25 Jul 2019 23:45:03 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 25 Jul 2019 23:45:02 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 25 Jul 2019 23:45:02 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.163]) with mapi id 14.03.0439.000; Fri, 26 Jul 2019 14:45:00 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Fan, ZhijuX" CC: "Feng, Bob C" Subject: Re: [edk2-devel] [PATCH V2] BaseTools:Updata the output encoding of the Popen function Thread-Topic: [edk2-devel] [PATCH V2] BaseTools:Updata the output encoding of the Popen function Thread-Index: AQHVQpWlXZgv4yVKJUu2YAORhQlZx6bcdhxQ Date: Fri, 26 Jul 2019 06:44:59 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4C278E@SHSMSX104.ccr.corp.intel.com> References: <20190725030312.16380-1-zhijux.fan@intel.com> In-Reply-To: <20190725030312.16380-1-zhijux.fan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Fan= , >ZhijuX >Sent: Thursday, July 25, 2019 11:03 AM >To: devel@edk2.groups.io >Cc: Feng, Bob C ; Gao, Liming >; Fan, ZhijuX >Subject: [edk2-devel] [PATCH V2] BaseTools:Updata the output encoding of >the Popen function > >From: Bob Feng > >BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2015 > >Not all output works in utf-8, so change the encoding to >the default > >This patch is going to fix that issue. > >Cc: Bob Feng >Cc: Liming Gao >Signed-off-by: Zhiju.Fan >--- > BaseTools/Source/Python/Common/Misc.py | 2 = +- > BaseTools/Source/Python/Common/VpdInfoFile.py | 2 = +- > BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py | 2 = +- > .../Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 6 >+++--- > BaseTools/Source/Python/Workspace/DscBuildData.py | 2 = +- > 5 files changed, 7 insertions(+), 7 deletions(-) > >diff --git a/BaseTools/Source/Python/Common/Misc.py >b/BaseTools/Source/Python/Common/Misc.py >index 9a63463913..36bd2fe364 100644 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -1092,7 +1092,7 @@ def ParseFieldValue (Value): > p.stderr.close() > if err: > raise BadExpression("DevicePath: %s" % str(err)) >- out =3D out.decode(encoding=3D'utf-8', errors=3D'ignore') >+ out =3D out.decode() > Size =3D len(out.split()) > out =3D ','.join(out.split()) > return '{' + out + '}', Size >diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py >b/BaseTools/Source/Python/Common/VpdInfoFile.py >index bc69a9010d..4249b9f899 100644 >--- a/BaseTools/Source/Python/Common/VpdInfoFile.py >+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py >@@ -243,7 +243,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): > except Exception as X: > EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, >ExtraData=3Dstr(X)) > (out, error) =3D PopenObject.communicate() >- print(out.decode(encoding=3D'utf-8', errors=3D'ignore')) >+ print(out.decode()) > while PopenObject.returncode is None : > PopenObject.wait() > >diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py >b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py >index 5630df55df..5d4c3a8599 100644 >--- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py >+++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py >@@ -116,7 +116,7 @@ if __name__ =3D=3D '__main__': > if Process.returncode !=3D 0: > print('ERROR: Open SSL command not available. Please verify PATH or= set >OPENSSL_PATH') > sys.exit(Process.returncode) >- print(Version[0].decode(encoding=3D'utf-8', errors=3D'ignore')) >+ print(Version[0].decode()) > > # > # Read input file into a buffer and save input filename >diff --git >a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey >s.py >b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey >s.py >index f9aed2bf86..6c9b8c464e 100644 >--- >a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey >s.py >+++ >b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey >s.py >@@ -78,7 +78,7 @@ if __name__ =3D=3D '__main__': > if Process.returncode !=3D 0: > print('ERROR: Open SSL command not available. Please verify PATH or= set >OPENSSL_PATH') > sys.exit(Process.returncode) >- print(Version[0].decode(encoding=3D'utf-8', errors=3D'ignore')) >+ print(Version[0].decode()) > > args.PemFileName =3D [] > >@@ -119,7 +119,7 @@ if __name__ =3D=3D '__main__': > # Extract public key from private key into STDOUT > # > Process =3D subprocess.Popen('%s rsa -in %s -modulus -noout' % >(OpenSslCommand, Item), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIP= E, >shell=3DTrue) >- PublicKeyHexString =3D Process.communicate()[0].decode(encoding=3D'u= tf-8', >errors=3D'ignore').split(b'=3D')[1].strip() >+ PublicKeyHexString =3D >Process.communicate()[0].decode().split(b'=3D')[1].strip() > if Process.returncode !=3D 0: > print('ERROR: Unable to extract public key from private key') > sys.exit(Process.returncode) >@@ -132,7 +132,7 @@ if __name__ =3D=3D '__main__': > # > Process =3D subprocess.Popen('%s dgst -sha256 -binary' % >(OpenSslCommand), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, >stderr=3Dsubprocess.PIPE, shell=3DTrue) > Process.stdin.write (PublicKey) >- PublicKeyHash =3D PublicKeyHash + >Process.communicate()[0].decode(encoding=3D'utf-8', errors=3D'ignore') >+ PublicKeyHash =3D PublicKeyHash + Process.communicate()[0].decode() > if Process.returncode !=3D 0: > print('ERROR: Unable to extract SHA 256 hash of public key') > sys.exit(Process.returncode) >diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py >b/BaseTools/Source/Python/Workspace/DscBuildData.py >index 985f877525..620e48fa7f 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -1735,7 +1735,7 @@ class DscBuildData(PlatformBuildClassObject): > except: > EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute >command: %s' % Command) > Result =3D Process.communicate() >- return Process.returncode, Result[0].decode(encoding=3D'utf-8', >errors=3D'ignore'), Result[1].decode(encoding=3D'utf-8', errors=3D'ignore= ') >+ return Process.returncode, Result[0].decode(), Result[1].decode(= ) > > @staticmethod > def IntToCString(Value, ValueSize): >-- >2.14.1.windows.1 > > >