mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Converted tclchksum.py to new classes.
This commit is contained in:
parent
77e947f77b
commit
e048b992d4
23
tclchksum.py
23
tclchksum.py
@ -5,14 +5,10 @@
|
|||||||
|
|
||||||
"""Return checksum for given firmware."""
|
"""Return checksum for given firmware."""
|
||||||
|
|
||||||
import random
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import tcllib
|
from tcllib import argparser
|
||||||
import tcllib.argparser
|
from tcllib.requests import RequestRunner, ChecksumRequest, ServerSelector
|
||||||
from tcllib.xmltools import pretty_xml
|
|
||||||
|
|
||||||
fc = tcllib.FotaCheck()
|
|
||||||
|
|
||||||
encslaves = [
|
encslaves = [
|
||||||
"54.238.56.196",
|
"54.238.56.196",
|
||||||
@ -29,7 +25,7 @@ encslaves = [
|
|||||||
dpdesc = """
|
dpdesc = """
|
||||||
Returns the checksum for a given firmware URI.
|
Returns the checksum for a given firmware URI.
|
||||||
"""
|
"""
|
||||||
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
||||||
dp.add_argument("uri", help="URI to firmware, starts with '/body/...'")
|
dp.add_argument("uri", help="URI to firmware, starts with '/body/...'")
|
||||||
args = dp.parse_args(sys.argv[1:])
|
args = dp.parse_args(sys.argv[1:])
|
||||||
|
|
||||||
@ -38,6 +34,13 @@ fileurl = args.uri
|
|||||||
# /body/ce570ddc079e2744558f191895e524d02a60476f/32/268932
|
# /body/ce570ddc079e2744558f191895e524d02a60476f/32/268932
|
||||||
#fileurl = "/body/ce570ddc079e2744558f191895e524d02a60476f/2c23717bb747f3c321195419f451de52efa8ea51/263790/268932"
|
#fileurl = "/body/ce570ddc079e2744558f191895e524d02a60476f/2c23717bb747f3c321195419f451de52efa8ea51/263790/268932"
|
||||||
|
|
||||||
chksum_xml = fc.do_checksum(random.choice(encslaves), fileurl, fileurl)
|
runner = RequestRunner(ServerSelector(encslaves), https=False)
|
||||||
print(pretty_xml(chksum_xml))
|
|
||||||
file_addr, sha1_body, sha1_enc_footer, sha1_footer = fc.parse_checksum(chksum_xml)
|
cks = ChecksumRequest(fileurl, fileurl)
|
||||||
|
runner.run(cks)
|
||||||
|
|
||||||
|
if not cks.success:
|
||||||
|
print("{}".format(cks.error))
|
||||||
|
sys.exit(4)
|
||||||
|
cksres = cks.get_result()
|
||||||
|
print(cksres.pretty_xml())
|
||||||
|
Loading…
Reference in New Issue
Block a user