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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Feng, Bob C
2019-01-23 10:16:00 +08:00
parent f8d11e5a4a
commit d943b0c339
37 changed files with 247 additions and 244 deletions

View File

@ -181,7 +181,7 @@ class Capsule (CapsuleClassObject):
#
# The real capsule header structure is 28 bytes
#
Header.write('\x00'*(HdrSize-28))
Header.write(b'\x00'*(HdrSize-28))
Header.write(FwMgrHdr.getvalue())
Header.write(Content.getvalue())
#
@ -206,18 +206,17 @@ class Capsule (CapsuleClassObject):
return self.GenFmpCapsule()
CapInfFile = self.GenCapInf()
CapInfFile.writelines("[files]" + TAB_LINE_BREAK)
CapInfFile.append("[files]" + TAB_LINE_BREAK)
CapFileList = []
for CapsuleDataObj in self.CapsuleDataList:
CapsuleDataObj.CapsuleName = self.CapsuleName
FileName = CapsuleDataObj.GenCapsuleSubItem()
CapsuleDataObj.CapsuleName = None
CapFileList.append(FileName)
CapInfFile.writelines("EFI_FILE_NAME = " + \
CapInfFile.append("EFI_FILE_NAME = " + \
FileName + \
TAB_LINE_BREAK)
SaveFileOnChange(self.CapInfFileName, CapInfFile.getvalue(), False)
CapInfFile.close()
SaveFileOnChange(self.CapInfFileName, ''.join(CapInfFile), False)
#
# Call GenFv tool to generate capsule
#
@ -243,12 +242,12 @@ class Capsule (CapsuleClassObject):
def GenCapInf(self):
self.CapInfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
self.UiCapsuleName + "_Cap" + '.inf')
CapInfFile = BytesIO() #open (self.CapInfFileName , 'w+')
CapInfFile = []
CapInfFile.writelines("[options]" + TAB_LINE_BREAK)
CapInfFile.append("[options]" + TAB_LINE_BREAK)
for Item in self.TokensDict:
CapInfFile.writelines("EFI_" + \
CapInfFile.append("EFI_" + \
Item + \
' = ' + \
self.TokensDict[Item] + \