* [PATCH V2] BaseTools:Updata the output encoding of the Popen function
@ 2019-07-25 3:03 Fan, ZhijuX
2019-07-26 6:44 ` [edk2-devel] " Liming Gao
0 siblings, 1 reply; 2+ messages in thread
From: Fan, ZhijuX @ 2019-07-25 3:03 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao, Zhiju . Fan
From: Bob Feng <bob.c.feng@intel.com>
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2015
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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
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 = out.decode(encoding='utf-8', errors='ignore')
+ out = out.decode()
Size = len(out.split())
out = ','.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=str(X))
(out, error) = PopenObject.communicate()
- print(out.decode(encoding='utf-8', errors='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__ == '__main__':
if Process.returncode != 0:
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print(Version[0].decode(encoding='utf-8', errors='ignore'))
+ print(Version[0].decode())
#
# Read input file into a buffer and save input filename
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index f9aed2bf86..6c9b8c464e 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -78,7 +78,7 @@ if __name__ == '__main__':
if Process.returncode != 0:
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
sys.exit(Process.returncode)
- print(Version[0].decode(encoding='utf-8', errors='ignore'))
+ print(Version[0].decode())
args.PemFileName = []
@@ -119,7 +119,7 @@ if __name__ == '__main__':
# Extract public key from private key into STDOUT
#
Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- PublicKeyHexString = Process.communicate()[0].decode(encoding='utf-8', errors='ignore').split(b'=')[1].strip()
+ PublicKeyHexString = Process.communicate()[0].decode().split(b'=')[1].strip()
if Process.returncode != 0:
print('ERROR: Unable to extract public key from private key')
sys.exit(Process.returncode)
@@ -132,7 +132,7 @@ if __name__ == '__main__':
#
Process = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Process.stdin.write (PublicKey)
- PublicKeyHash = PublicKeyHash + Process.communicate()[0].decode(encoding='utf-8', errors='ignore')
+ PublicKeyHash = PublicKeyHash + Process.communicate()[0].decode()
if Process.returncode != 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 = Process.communicate()
- return Process.returncode, Result[0].decode(encoding='utf-8', errors='ignore'), Result[1].decode(encoding='utf-8', errors='ignore')
+ return Process.returncode, Result[0].decode(), Result[1].decode()
@staticmethod
def IntToCString(Value, ValueSize):
--
2.14.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [PATCH V2] BaseTools:Updata the output encoding of the Popen function
2019-07-25 3:03 [PATCH V2] BaseTools:Updata the output encoding of the Popen function Fan, ZhijuX
@ 2019-07-26 6:44 ` Liming Gao
0 siblings, 0 replies; 2+ messages in thread
From: Liming Gao @ 2019-07-26 6:44 UTC (permalink / raw)
To: devel@edk2.groups.io, Fan, ZhijuX; +Cc: Feng, Bob C
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----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 <bob.c.feng@intel.com>; Gao, Liming
><liming.gao@intel.com>; Fan, ZhijuX <zhijux.fan@intel.com>
>Subject: [edk2-devel] [PATCH V2] BaseTools:Updata the output encoding of
>the Popen function
>
>From: Bob Feng <bob.c.feng@intel.com>
>
>BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2015
>
>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 <bob.c.feng@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
>---
> 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 = out.decode(encoding='utf-8', errors='ignore')
>+ out = out.decode()
> Size = len(out.split())
> out = ','.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=str(X))
> (out, error) = PopenObject.communicate()
>- print(out.decode(encoding='utf-8', errors='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__ == '__main__':
> if Process.returncode != 0:
> print('ERROR: Open SSL command not available. Please verify PATH or set
>OPENSSL_PATH')
> sys.exit(Process.returncode)
>- print(Version[0].decode(encoding='utf-8', errors='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__ == '__main__':
> if Process.returncode != 0:
> print('ERROR: Open SSL command not available. Please verify PATH or set
>OPENSSL_PATH')
> sys.exit(Process.returncode)
>- print(Version[0].decode(encoding='utf-8', errors='ignore'))
>+ print(Version[0].decode())
>
> args.PemFileName = []
>
>@@ -119,7 +119,7 @@ if __name__ == '__main__':
> # Extract public key from private key into STDOUT
> #
> Process = subprocess.Popen('%s rsa -in %s -modulus -noout' %
>(OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE,
>shell=True)
>- PublicKeyHexString = Process.communicate()[0].decode(encoding='utf-8',
>errors='ignore').split(b'=')[1].strip()
>+ PublicKeyHexString =
>Process.communicate()[0].decode().split(b'=')[1].strip()
> if Process.returncode != 0:
> print('ERROR: Unable to extract public key from private key')
> sys.exit(Process.returncode)
>@@ -132,7 +132,7 @@ if __name__ == '__main__':
> #
> Process = subprocess.Popen('%s dgst -sha256 -binary' %
>(OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE,
>stderr=subprocess.PIPE, shell=True)
> Process.stdin.write (PublicKey)
>- PublicKeyHash = PublicKeyHash +
>Process.communicate()[0].decode(encoding='utf-8', errors='ignore')
>+ PublicKeyHash = PublicKeyHash + Process.communicate()[0].decode()
> if Process.returncode != 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 = Process.communicate()
>- return Process.returncode, Result[0].decode(encoding='utf-8',
>errors='ignore'), Result[1].decode(encoding='utf-8', errors='ignore')
>+ return Process.returncode, Result[0].decode(), Result[1].decode()
>
> @staticmethod
> def IntToCString(Value, ValueSize):
>--
>2.14.1.windows.1
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-26 6:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-25 3:03 [PATCH V2] BaseTools:Updata the output encoding of the Popen function Fan, ZhijuX
2019-07-26 6:44 ` [edk2-devel] " Liming Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox