mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Parser for checksum.php result.
This commit is contained in:
parent
17d465fc87
commit
827e0ae615
@ -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)
|
||||
print(fc.pretty_xml(chksum_xml))
|
||||
file_addr, sha1_body, sha1_enc_footer, sha1_footer = fc.parse_checksum(chksum_xml)
|
||||
|
||||
for s in slaves:
|
||||
print("http://{}{}".format(s, fileurl))
|
||||
@ -86,6 +87,7 @@ if fc.mode == fc.MODE.FULL:
|
||||
if not os.path.exists(headdir):
|
||||
os.makedirs(headdir)
|
||||
if len(header) == 4194320:
|
||||
# TODO: Check sha1sum
|
||||
print("Header length check passed. Writing to {}.".format(headname))
|
||||
with open(os.path.join(headdir, headname), "wb") as f:
|
||||
f.write(header)
|
||||
|
10
tcllib.py
10
tcllib.py
@ -419,3 +419,13 @@ class FotaCheck:
|
||||
print(repr(req.headers))
|
||||
print(repr(req.text))
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user