mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Scanner for unknown models.
This commit is contained in:
parent
8fc6590cf9
commit
f0bdc0af75
66
tclcheck_findprd2.py
Normal file
66
tclcheck_findprd2.py
Normal file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# pylint: disable=C0111,C0326,C0103
|
||||
|
||||
import collections
|
||||
import sys
|
||||
import tcllib
|
||||
from requests.exceptions import RequestException, Timeout
|
||||
|
||||
# Variants to scan for
|
||||
SCAN_VARIANTS = ["001", "003", "009", "010", "700"]
|
||||
|
||||
tcllib.make_escapes_work()
|
||||
|
||||
fc = tcllib.FotaCheck()
|
||||
fc.serid = "3531510"
|
||||
fc.fv = "AAA000"
|
||||
fc.mode = fc.MODE.FULL
|
||||
|
||||
# CLTP = 10 (only show actual updates or HTTP 206) / 2010 (always show latest version for MODE.FULL)
|
||||
#fc.cltp = fc.CLTP.MOBILE
|
||||
fc.cltp = fc.CLTP.DESKTOP
|
||||
|
||||
dp = tcllib.DefaultParser(__file__)
|
||||
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)
|
||||
args = dp.parse_args(sys.argv[1:])
|
||||
|
||||
floor = args.floor
|
||||
ceiling = args.ceiling + 1
|
||||
if ceiling < floor:
|
||||
print("Invalid range!")
|
||||
raise SystemExit
|
||||
|
||||
print("Loading list of known devices...", end="", flush=True)
|
||||
prd_db = tcllib.FotaCheck.get_devicelist()
|
||||
print(" OK")
|
||||
|
||||
print("Valid PRDs not already in database:")
|
||||
|
||||
known_centers = set(int(x.replace("PRD-", "").split("-")[0]) for x in prd_db)
|
||||
scan_list = set(range(floor, ceiling))
|
||||
|
||||
to_scan = scan_list - known_centers
|
||||
total_count = len(to_scan) * len(SCAN_VARIANTS)
|
||||
done_count = 0
|
||||
|
||||
for center in to_scan:
|
||||
for j in SCAN_VARIANTS:
|
||||
curef = "PRD-{:05}-{:3}".format(center, j)
|
||||
done_count += 1
|
||||
print("Checking {} ({}/{})".format(curef, done_count, total_count))
|
||||
print(tcllib.ANSI_UP_DEL, end="")
|
||||
try:
|
||||
fc.reset_session()
|
||||
fc.curef = curef
|
||||
check_xml = fc.do_check(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
|
||||
|
||||
print("Scan complete.")
|
||||
tcllib.FotaCheck.write_info_if_dumps_found()
|
Loading…
Reference in New Issue
Block a user