mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Convert tclcheck_findver.py to new style.
This commit is contained in:
parent
072644a089
commit
dfe366dd7c
@ -7,32 +7,28 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from requests.exceptions import RequestException, Timeout
|
from tcllib import ansi, argparser, devlist
|
||||||
|
from tcllib.devices import MobileDevice
|
||||||
|
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, \
|
||||||
|
write_info_if_dumps_found
|
||||||
|
|
||||||
import tcllib
|
|
||||||
import tcllib.argparser
|
|
||||||
from tcllib import ansi
|
|
||||||
from tcllib.devices import DesktopDevice, MobileDevice
|
|
||||||
|
|
||||||
|
|
||||||
dev = MobileDevice()
|
|
||||||
fc = tcllib.FotaCheck()
|
|
||||||
|
|
||||||
dpdesc = """
|
dpdesc = """
|
||||||
Finds all valid OTA updates for a given PRD. Scan range can be set by
|
Finds all valid OTA updates for a given PRD. Scan range can be set by
|
||||||
startver and endver switches.
|
startver and endver switches.
|
||||||
"""
|
"""
|
||||||
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
||||||
dp.add_argument("prd", help="CU Reference #, e.g. PRD-63117-011")
|
dp.add_argument("prd", help="CU Reference #, e.g. PRD-63117-011")
|
||||||
dp.add_argument("startver", help="Beginning of scan range", nargs="?", default="AAA000")
|
dp.add_argument("startver", help="Beginning of scan range", nargs="?", default="AAA000")
|
||||||
dp.add_argument("endver", help="End of scan range", nargs="?", default="AAZ999")
|
dp.add_argument("endver", help="End of scan range", nargs="?", default="AAZ999")
|
||||||
args = dp.parse_args(sys.argv[1:])
|
args = dp.parse_args(sys.argv[1:])
|
||||||
|
|
||||||
fc.curef = args.prd
|
dev = MobileDevice()
|
||||||
|
dev.curef = args.prd
|
||||||
start_ver = args.startver
|
start_ver = args.startver
|
||||||
end_ver = args.endver
|
end_ver = args.endver
|
||||||
|
|
||||||
print("Valid firmwares for model {} (between {} and {}):".format(fc.curef, start_ver, end_ver))
|
print("Valid firmwares for model {} (between {} and {}):".format(dev.curef, start_ver, end_ver))
|
||||||
|
|
||||||
cur_ver = start_ver
|
cur_ver = start_ver
|
||||||
allvers = []
|
allvers = []
|
||||||
@ -53,21 +49,22 @@ while True:
|
|||||||
break
|
break
|
||||||
cur_ver = "{:3}{:03d}".format("".join(letters), num)
|
cur_ver = "{:3}{:03d}".format("".join(letters), num)
|
||||||
|
|
||||||
|
runner = RequestRunner(ServerVoteSelector(), https=False)
|
||||||
|
runner.max_tries = 20
|
||||||
|
|
||||||
done_count = 0
|
done_count = 0
|
||||||
total_count = len(allvers)
|
total_count = len(allvers)
|
||||||
for fv in allvers:
|
for fv in allvers:
|
||||||
done_count += 1
|
done_count += 1
|
||||||
print("Checking {} ({}/{})".format(fv, done_count, total_count))
|
print("Checking {} ({}/{})".format(fv, done_count, total_count))
|
||||||
print(ansi.UP_DEL, end="")
|
print(ansi.UP_DEL, end="")
|
||||||
try:
|
|
||||||
dev.fwver = fv
|
dev.fwver = fv
|
||||||
fc.reset_session(dev)
|
chk = CheckRequest(dev)
|
||||||
check_xml = fc.do_check(dev, https=False, max_tries=20)
|
runner.run(chk)
|
||||||
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
if chk.success:
|
||||||
txt_tv = tv
|
chkres = chk.get_result()
|
||||||
print("{}: {} ⇨ {} {}".format(curef, fv, txt_tv, fhash))
|
txt_tv = chkres.tvver
|
||||||
except (SystemExit, RequestException, Timeout) as e:
|
print("{}: {} ⇨ {} {}".format(curef, fv, txt_tv, chkres.filehash))
|
||||||
continue
|
|
||||||
|
|
||||||
print("Scan complete.")
|
print("Scan complete.")
|
||||||
tcllib.FotaCheck.write_info_if_dumps_found()
|
write_info_if_dumps_found()
|
||||||
|
Loading…
Reference in New Issue
Block a user