From d943b0c339fe3d35ffdf9f580ccb7a55915c6854 Mon Sep 17 00:00:00 2001 From: "Feng, Bob C" Date: Wed, 23 Jan 2019 10:16:00 +0800 Subject: BaseTools: Handle the bytes and str difference Deal with bytes and str is different, remove the unicode(), correct open file parameter. Using utcfromtimestamp instead of fromtimestamp. Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Tested-by: Laszlo Ersek Tested-by: Ard Biesheuvel Reviewed-by: Liming Gao Reviewed-by: Bob Feng --- BaseTools/Source/Python/Common/VpdInfoFile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'BaseTools/Source/Python/Common/VpdInfoFile.py') diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index cebc1f7187..e6cc768ee1 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -92,18 +92,18 @@ class VpdInfoFile: if (Vpd is None): EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.") - if not (Offset >= 0 or Offset == TAB_STAR): + if not (Offset >= "0" or Offset == TAB_STAR): EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset) if Vpd.DatumType == TAB_VOID: - if Vpd.MaxDatumSize <= 0: + if Vpd.MaxDatumSize <= "0": EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES: if not Vpd.MaxDatumSize: Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType] else: - if Vpd.MaxDatumSize <= 0: + if Vpd.MaxDatumSize <= "0": EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) @@ -127,7 +127,7 @@ class VpdInfoFile: "Invalid parameter FilePath: %s." % FilePath) Content = FILE_COMMENT_TEMPLATE - Pcds = sorted(self._VpdArray.keys()) + Pcds = sorted(self._VpdArray.keys(), key=lambda x: x.TokenCName) for Pcd in Pcds: i = 0 PcdTokenCName = Pcd.TokenCName @@ -249,7 +249,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): except Exception as X: EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X)) (out, error) = PopenObject.communicate() - print(out) + print(out.decode(encoding='utf-8', errors='ignore')) while PopenObject.returncode is None : PopenObject.wait() -- cgit v1.2.3