From dd8be7be3b6a0e9d2d72aa6774064f2c83f3471f Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 11 Feb 2018 01:21:09 +0100 Subject: [PATCH] Converted tclcheck_findprd.py --- tclcheck_findprd.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tclcheck_findprd.py b/tclcheck_findprd.py index 46950e4..d04c43a 100755 --- a/tclcheck_findprd.py +++ b/tclcheck_findprd.py @@ -10,15 +10,13 @@ import sys from requests.exceptions import RequestException, Timeout -import tcllib import tcllib.argparser from tcllib import ansi, devlist -from tcllib.devices import DesktopDevice, MobileDevice +from tcllib.devices import DesktopDevice +from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, \ + write_info_if_dumps_found -dev = DesktopDevice() -fc = tcllib.FotaCheck() - dpdesc = """ Finds new PRD numbers for all known variants, or specified variants with tocheck. Scan range can be set by floor and ceiling switches. @@ -58,6 +56,11 @@ if args.tocheck is not None: if not prddict: prddict[args.tocheck] = [] +dev = DesktopDevice() + +runner = RequestRunner(ServerVoteSelector(), https=False) +runner.max_tries = 20 + for center in sorted(prddict.keys()): tails = [int(i) for i in prddict[center]] safes = [g for g in range(floor, ceiling) if g not in tails] @@ -69,15 +72,13 @@ for center in sorted(prddict.keys()): done_count += 1 print("Checking {} ({}/{})".format(curef, done_count, total_count)) print(ansi.UP_DEL, end="") - try: - dev.curef = curef - fc.reset_session(dev) - check_xml = fc.do_check(dev, https=False, max_tries=20) - curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml) - txt_tv = tv - print("{}: {} {}".format(curef, txt_tv, fhash)) - except (SystemExit, RequestException, Timeout) as e: - continue + dev.curef = curef + chk = CheckRequest(dev) + runner.run(chk) + if chk.success: + chkres = chk.get_result() + txt_tv = chkres.tvver + print("{}: {} {}".format(curef, txt_tv, chkres.filehash)) print("Scan complete.") -tcllib.FotaCheck.write_info_if_dumps_found() +write_info_if_dumps_found()