mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Converted tclcheck_findprd2.py
This commit is contained in:
parent
dd8be7be3b
commit
072644a089
@ -8,10 +8,7 @@
|
|||||||
import collections
|
import collections
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from requests.exceptions import RequestException, Timeout
|
from tcllib import ansi, argparser, devlist
|
||||||
|
|
||||||
import tcllib.argparser
|
|
||||||
from tcllib import ansi, devlist
|
|
||||||
from tcllib.devices import DesktopDevice
|
from tcllib.devices import DesktopDevice
|
||||||
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, \
|
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, \
|
||||||
write_info_if_dumps_found
|
write_info_if_dumps_found
|
||||||
@ -21,7 +18,7 @@ dpdesc = """
|
|||||||
Finds new PRD numbers for all known variants, or specified variants with tocheck. Scan range
|
Finds new PRD numbers for all known variants, or specified variants with tocheck. Scan range
|
||||||
can be set by floor and ceiling switches.
|
can be set by floor and ceiling switches.
|
||||||
"""
|
"""
|
||||||
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
||||||
dp.add_argument("tocheck", help="CU Reference # to filter scan results", nargs="?", default=None)
|
dp.add_argument("tocheck", help="CU Reference # to filter scan results", nargs="?", default=None)
|
||||||
dp.add_argument("-f", "--floor", help="Beginning of scan range", dest="floor", nargs="?", type=int, default=0)
|
dp.add_argument("-f", "--floor", help="Beginning of scan range", dest="floor", nargs="?", type=int, default=0)
|
||||||
dp.add_argument("-c", "--ceiling", help="End of scan range", dest="ceiling", nargs="?", type=int, default=999)
|
dp.add_argument("-c", "--ceiling", help="End of scan range", dest="ceiling", nargs="?", type=int, default=999)
|
||||||
|
@ -7,25 +7,20 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from requests.exceptions import RequestException, Timeout
|
from tcllib import ansi, argparser, devlist
|
||||||
|
from tcllib.devices import DesktopDevice
|
||||||
import tcllib
|
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, \
|
||||||
import tcllib.argparser
|
write_info_if_dumps_found
|
||||||
from tcllib import ansi, devlist
|
|
||||||
from tcllib.devices import DesktopDevice, MobileDevice
|
|
||||||
|
|
||||||
|
|
||||||
# Variants to scan for
|
# Variants to scan for
|
||||||
SCAN_VARIANTS = ["001", "003", "009", "010", "700"]
|
SCAN_VARIANTS = ["001", "003", "009", "010", "700"]
|
||||||
|
|
||||||
dev = DesktopDevice()
|
|
||||||
fc = tcllib.FotaCheck()
|
|
||||||
|
|
||||||
dpdesc = """
|
dpdesc = """
|
||||||
Finds new PRD numbers for a range of variants. Scan range can be set by
|
Finds new PRD numbers for a range of variants. Scan range can be set by
|
||||||
floor and ceiling switches.
|
floor and ceiling switches.
|
||||||
"""
|
"""
|
||||||
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
||||||
dp.add_argument("floor", nargs="?", help="Model number to start with", type=int, default=63116)
|
dp.add_argument("floor", nargs="?", help="Model number to start with", type=int, default=63116)
|
||||||
dp.add_argument("ceiling", nargs="?", help="Model number to end with", type=int, default=99999)
|
dp.add_argument("ceiling", nargs="?", help="Model number to end with", type=int, default=99999)
|
||||||
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)
|
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)
|
||||||
@ -50,21 +45,24 @@ to_scan = scan_list - known_centers
|
|||||||
total_count = len(to_scan) * len(SCAN_VARIANTS)
|
total_count = len(to_scan) * len(SCAN_VARIANTS)
|
||||||
done_count = 0
|
done_count = 0
|
||||||
|
|
||||||
|
dev = DesktopDevice()
|
||||||
|
|
||||||
|
runner = RequestRunner(ServerVoteSelector(), https=False)
|
||||||
|
runner.max_tries = 20
|
||||||
|
|
||||||
for center in to_scan:
|
for center in to_scan:
|
||||||
for j in SCAN_VARIANTS:
|
for j in SCAN_VARIANTS:
|
||||||
curef = "PRD-{:05}-{:3}".format(center, j)
|
curef = "PRD-{:05}-{:3}".format(center, j)
|
||||||
done_count += 1
|
done_count += 1
|
||||||
print("Checking {} ({}/{})".format(curef, done_count, total_count))
|
print("Checking {} ({}/{})".format(curef, done_count, total_count))
|
||||||
print(ansi.UP_DEL, end="")
|
print(ansi.UP_DEL, end="")
|
||||||
try:
|
|
||||||
dev.curef = curef
|
dev.curef = curef
|
||||||
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, txt_tv, fhash))
|
txt_tv = chkres.tvver
|
||||||
except (SystemExit, RequestException, Timeout) as e:
|
print("{}: {} {}".format(curef, 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