2018-01-23 21:59:21 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# pylint: disable=C0111,C0326,C0103
|
|
|
|
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Find new PRDs for a range of variants."""
|
|
|
|
|
2018-01-23 21:59:21 +00:00
|
|
|
import sys
|
2018-02-03 20:24:36 +00:00
|
|
|
|
|
|
|
from requests.exceptions import RequestException, Timeout
|
|
|
|
|
2018-01-23 21:59:21 +00:00
|
|
|
import tcllib
|
2018-02-02 02:33:53 +00:00
|
|
|
import tcllib.argparser
|
2018-02-06 00:03:25 +00:00
|
|
|
from tcllib import ansi, devlist
|
2018-02-07 00:49:44 +00:00
|
|
|
from tcllib.devices import DesktopDevice, MobileDevice
|
2018-02-03 20:24:36 +00:00
|
|
|
|
2018-01-23 21:59:21 +00:00
|
|
|
|
|
|
|
# Variants to scan for
|
|
|
|
SCAN_VARIANTS = ["001", "003", "009", "010", "700"]
|
|
|
|
|
2018-02-07 00:49:44 +00:00
|
|
|
dev = DesktopDevice()
|
2018-01-23 21:59:21 +00:00
|
|
|
fc = tcllib.FotaCheck()
|
|
|
|
|
2018-01-30 17:31:05 +00:00
|
|
|
dpdesc = """
|
|
|
|
Finds new PRD numbers for a range of variants. Scan range can be set by
|
|
|
|
floor and ceiling switches.
|
|
|
|
"""
|
2018-02-02 02:33:53 +00:00
|
|
|
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
2018-01-23 21:59:21 +00:00
|
|
|
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)
|
2018-02-09 20:41:12 +00:00
|
|
|
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)
|
2018-01-23 21:59:21 +00:00
|
|
|
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)
|
2018-02-09 20:41:12 +00:00
|
|
|
prd_db = devlist.get_devicelist(local=args.local)
|
2018-01-23 21:59:21 +00:00
|
|
|
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))
|
2018-02-03 00:36:08 +00:00
|
|
|
print(ansi.UP_DEL, end="")
|
2018-01-23 21:59:21 +00:00
|
|
|
try:
|
2018-02-07 00:49:44 +00:00
|
|
|
dev.curef = curef
|
|
|
|
fc.reset_session(dev)
|
|
|
|
check_xml = fc.do_check(dev, https=False, max_tries=20)
|
2018-01-23 21:59:21 +00:00
|
|
|
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()
|