summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/Capsule.py
diff options
context:
space:
mode:
authorFeng, Bob C <bob.c.feng@intel.com>2019-01-23 10:16:00 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-02-01 11:09:24 +0800
commitd943b0c339fe3d35ffdf9f580ccb7a55915c6854 (patch)
treef48623041095431d49c3cb8ce7f1a8dab953f26e /BaseTools/Source/Python/GenFds/Capsule.py
parentf8d11e5a4aaa90bf63b4789f3993dd6d16c60787 (diff)
downloadedk2-d943b0c339fe3d35ffdf9f580ccb7a55915c6854.tar.gz
edk2-d943b0c339fe3d35ffdf9f580ccb7a55915c6854.tar.bz2
edk2-d943b0c339fe3d35ffdf9f580ccb7a55915c6854.zip
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>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/Capsule.py')
-rw-r--r--BaseTools/Source/Python/GenFds/Capsule.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 1cdbdcf7ba..9013fca410 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -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] + \