2018-02-08 00:15:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-02-10 01:38:06 +00:00
|
|
|
import xml.dom.minidom
|
|
|
|
|
2018-02-08 00:15:58 +00:00
|
|
|
from defusedxml import ElementTree
|
|
|
|
|
2018-02-08 23:17:08 +00:00
|
|
|
from . import dumpmgr
|
|
|
|
|
2018-02-08 00:15:58 +00:00
|
|
|
|
|
|
|
class TclResult:
|
2018-02-08 23:17:08 +00:00
|
|
|
def __init__(self, xml: str):
|
|
|
|
self.raw_xml = xml
|
|
|
|
self.dumper = dumpmgr.DumpMgr()
|
|
|
|
self.dumper.write_dump(xml)
|
|
|
|
|
|
|
|
def delete_dump(self):
|
|
|
|
self.dumper.delete_last_dump()
|
2018-02-08 00:15:58 +00:00
|
|
|
|
2018-02-10 01:38:06 +00:00
|
|
|
def pretty_xml(self):
|
|
|
|
"""Return prettified input XML with ``xml.dom.minidom``."""
|
|
|
|
mdx = xml.dom.minidom.parseString(self.raw_xml)
|
|
|
|
return mdx.toprettyxml(indent=" ")
|
|
|
|
|
2018-02-08 00:15:58 +00:00
|
|
|
class CheckResult(TclResult):
|
|
|
|
def __init__(self, xml: str):
|
2018-02-08 23:17:08 +00:00
|
|
|
super().__init__(xml)
|
2018-02-08 00:15:58 +00:00
|
|
|
root = ElementTree.fromstring(xml)
|
|
|
|
self.curef = root.find("CUREF").text
|
|
|
|
self.fvver = root.find("VERSION").find("FV").text
|
|
|
|
self.tvver = root.find("VERSION").find("TV").text
|
|
|
|
self.fw_id = root.find("FIRMWARE").find("FW_ID").text
|
|
|
|
fileinfo = root.find("FIRMWARE").find("FILESET").find("FILE")
|
|
|
|
self.fileid = fileinfo.find("FILE_ID").text
|
|
|
|
self.filename = fileinfo.find("FILENAME").text
|
|
|
|
self.filesize = fileinfo.find("SIZE").text
|
|
|
|
self.filehash = fileinfo.find("CHECKSUM").text
|