mirror of https://github.com/acidanthera/audk.git
BaseTools:Updata the output encoding of the Popen function
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> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
307e1650be
commit
8ddec24dea
|
@ -1087,7 +1087,7 @@ def ParseFieldValue (Value):
|
||||||
p.stderr.close()
|
p.stderr.close()
|
||||||
if err:
|
if err:
|
||||||
raise BadExpression("DevicePath: %s" % str(err))
|
raise BadExpression("DevicePath: %s" % str(err))
|
||||||
out = out.decode(encoding='utf-8', errors='ignore')
|
out = out.decode()
|
||||||
Size = len(out.split())
|
Size = len(out.split())
|
||||||
out = ','.join(out.split())
|
out = ','.join(out.split())
|
||||||
return '{' + out + '}', Size
|
return '{' + out + '}', Size
|
||||||
|
|
|
@ -243,7 +243,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
|
||||||
except Exception as X:
|
except Exception as X:
|
||||||
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))
|
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))
|
||||||
(out, error) = PopenObject.communicate()
|
(out, error) = PopenObject.communicate()
|
||||||
print(out.decode(encoding='utf-8', errors='ignore'))
|
print(out.decode())
|
||||||
while PopenObject.returncode is None :
|
while PopenObject.returncode is None :
|
||||||
PopenObject.wait()
|
PopenObject.wait()
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ if __name__ == '__main__':
|
||||||
if Process.returncode != 0:
|
if Process.returncode != 0:
|
||||||
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
|
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
|
||||||
sys.exit(Process.returncode)
|
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
|
# Read input file into a buffer and save input filename
|
||||||
|
|
|
@ -78,7 +78,7 @@ if __name__ == '__main__':
|
||||||
if Process.returncode != 0:
|
if Process.returncode != 0:
|
||||||
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
|
print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')
|
||||||
sys.exit(Process.returncode)
|
sys.exit(Process.returncode)
|
||||||
print(Version[0].decode(encoding='utf-8', errors='ignore'))
|
print(Version[0].decode())
|
||||||
|
|
||||||
args.PemFileName = []
|
args.PemFileName = []
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ if __name__ == '__main__':
|
||||||
# Extract public key from private key into STDOUT
|
# 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)
|
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:
|
if Process.returncode != 0:
|
||||||
print('ERROR: Unable to extract public key from private key')
|
print('ERROR: Unable to extract public key from private key')
|
||||||
sys.exit(Process.returncode)
|
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 = subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslCommand), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
Process.stdin.write (PublicKey)
|
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:
|
if Process.returncode != 0:
|
||||||
print('ERROR: Unable to extract SHA 256 hash of public key')
|
print('ERROR: Unable to extract SHA 256 hash of public key')
|
||||||
sys.exit(Process.returncode)
|
sys.exit(Process.returncode)
|
||||||
|
|
|
@ -1735,7 +1735,7 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
except:
|
except:
|
||||||
EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command)
|
EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command)
|
||||||
Result = Process.communicate()
|
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
|
@staticmethod
|
||||||
def IntToCString(Value, ValueSize):
|
def IntToCString(Value, ValueSize):
|
||||||
|
|
Loading…
Reference in New Issue