summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/build/BuildReport.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/build/BuildReport.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/build/BuildReport.py')
-rw-r--r--BaseTools/Source/Python/build/BuildReport.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 1cd1b0886a..8d3b030151 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -143,7 +143,7 @@ VPDPcdList = []
def FileWrite(File, String, Wrapper=False):
if Wrapper:
String = textwrap.fill(String, 120)
- File.write(String + gEndOfLine)
+ File.append(String + gEndOfLine)
def ByteArrayForamt(Value):
IsByteArray = False
@@ -636,7 +636,7 @@ class ModuleReport(object):
Match = gTimeStampPattern.search(FileContents)
if Match:
- self.BuildTimeStamp = datetime.fromtimestamp(int(Match.group(1)))
+ self.BuildTimeStamp = datetime.utcfromtimestamp(int(Match.group(1)))
except IOError:
EdkLogger.warn(None, "Fail to read report file", FwReportFileName)
@@ -721,8 +721,8 @@ def ReadMessage(From, To, ExitFlag):
# read one line a time
Line = From.readline()
# empty string means "end"
- if Line is not None and Line != "":
- To(Line.rstrip())
+ if Line is not None and Line != b"":
+ To(Line.rstrip().decode(encoding='utf-8', errors='ignore'))
else:
break
if ExitFlag.isSet():
@@ -2269,18 +2269,17 @@ class BuildReport(object):
def GenerateReport(self, BuildDuration, AutoGenTime, MakeTime, GenFdsTime):
if self.ReportFile:
try:
- File = BytesIO('')
+ File = []
for (Wa, MaList) in self.ReportList:
PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, AutoGenTime, MakeTime, GenFdsTime, self.ReportType)
- Content = FileLinesSplit(File.getvalue(), gLineMaxLength)
- SaveFileOnChange(self.ReportFile, Content, True)
+ Content = FileLinesSplit(''.join(File), gLineMaxLength)
+ SaveFileOnChange(self.ReportFile, Content, False)
EdkLogger.quiet("Build report can be found at %s" % os.path.abspath(self.ReportFile))
except IOError:
EdkLogger.error(None, FILE_WRITE_FAILURE, ExtraData=self.ReportFile)
except:
EdkLogger.error("BuildReport", CODE_ERROR, "Unknown fatal error when generating build report", ExtraData=self.ReportFile, RaiseError=False)
EdkLogger.quiet("(Python %s on %s\n%s)" % (platform.python_version(), sys.platform, traceback.format_exc()))
- File.close()
# This acts like the main() function for the script, unless it is 'import'ed into another script.
if __name__ == '__main__':