in UefiTestingPkg/AuditTests/PagingAudit/Windows/PagingReportGenerator.py [0:0]
def OutputHtmlReport(self, ToolVersion, OutputFilePath):
# Create the dictionary to produce a JSON string.
json_dict = {
'ToolVersion': ToolVersion,
'PlatformVersion': self.PlatformVersion,
'PlatformName': self.PlatformName,
'DateCollected': datetime.datetime.strftime(datetime.datetime.now(), "%A, %B %d, %Y %I:%M%p" ),
}
# Process all of the Page Infos and add them to the JSON.
pde_infos = []
for pde in self.PageDirectoryInfo:
info_dict = pde.toDictionary()
# Check for errors.
if info_dict['Section Type'] == "ERROR":
self.AddErrorMsg("Page Descriptor at %s has an error parsing the Section Type." % info_dict['Start'])
pde_infos.append(info_dict)
json_dict['MemoryRanges'] = pde_infos
# Finally, add any errors and produce the JSON string.
json_dict['errors'] = self.ErrorMsg
js = json.dumps(json_dict)
#
# Open template and replace placeholder with json
#
f = open(OutputFilePath, "w")
if self.Type == 'DXE':
template = open(os.path.join(sp, "DxePaging_template.html"), "r")
else:
template = open(os.path.join(sp, "SmmPaging_template.html"), "r")
for line in template.readlines():
if "%TO_BE_FILLED_IN_BY_PYTHON_SCRIPT%" in line:
line = line.replace("%TO_BE_FILLED_IN_BY_PYTHON_SCRIPT%", js)
f.write(line)
template.close()
f.close()
return 0