1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-10 06:16:46 +00:00

Parser for checksum.php result.

This commit is contained in:
Markus Birth 2018-01-12 02:36:51 +01:00
parent 17d465fc87
commit 827e0ae615
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
2 changed files with 12 additions and 0 deletions

View File

@ -72,6 +72,7 @@ fileid, fileurl, slaves, encslaves, s3_fileurl, s3_slaves = fc.parse_request(req
chksum_xml = fc.do_checksum(random.choice(encslaves), fileurl, fileurl) chksum_xml = fc.do_checksum(random.choice(encslaves), fileurl, fileurl)
print(fc.pretty_xml(chksum_xml)) print(fc.pretty_xml(chksum_xml))
file_addr, sha1_body, sha1_enc_footer, sha1_footer = fc.parse_checksum(chksum_xml)
for s in slaves: for s in slaves:
print("http://{}{}".format(s, fileurl)) print("http://{}{}".format(s, fileurl))
@ -86,6 +87,7 @@ if fc.mode == fc.MODE.FULL:
if not os.path.exists(headdir): if not os.path.exists(headdir):
os.makedirs(headdir) os.makedirs(headdir)
if len(header) == 4194320: if len(header) == 4194320:
# TODO: Check sha1sum
print("Header length check passed. Writing to {}.".format(headname)) print("Header length check passed. Writing to {}.".format(headname))
with open(os.path.join(headdir, headname), "wb") as f: with open(os.path.join(headdir, headname), "wb") as f:
f.write(header) f.write(header)

View File

@ -419,3 +419,13 @@ class FotaCheck:
print(repr(req.headers)) print(repr(req.headers))
print(repr(req.text)) print(repr(req.text))
raise SystemExit raise SystemExit
@staticmethod
def parse_checksum(xmlstr):
root = ElementTree.fromstring(xmlstr)
file = root.find("FILE_CHECKSUM_LIST").find("FILE")
file_addr = file.find("ADDRESS").text
sha1_enc_footer = file.find("ENCRYPT_FOOTER").text
sha1_footer = file.find("FOOTER").text
sha1_body = file.find("BODY").text
return file_addr, sha1_body, sha1_enc_footer, sha1_footer