2017-09-19 16:12:01 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-10-05 22:51:07 +01:00
|
|
|
# pylint: disable=C0111,C0326,C0103
|
2017-09-19 16:12:01 +01:00
|
|
|
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Check all/given PRDs for OTA updates."""
|
|
|
|
|
2017-10-04 11:53:04 +01:00
|
|
|
import sys
|
2018-02-03 20:24:36 +00:00
|
|
|
|
|
|
|
from requests.exceptions import RequestException
|
|
|
|
|
2017-09-19 16:12:01 +01: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:22:09 +00:00
|
|
|
from tcllib.devices import MobileDevice
|
2018-02-03 20:24:36 +00:00
|
|
|
|
2017-09-19 16:12:01 +01:00
|
|
|
|
2018-02-07 00:22:09 +00:00
|
|
|
dev = MobileDevice()
|
2017-09-19 16:12:01 +01:00
|
|
|
fc = tcllib.FotaCheck()
|
|
|
|
|
2018-01-30 17:31:05 +00:00
|
|
|
dpdesc = """
|
|
|
|
Checks for the latest OTA updates for all PRD numbers or only for the PRD specified
|
|
|
|
as prd. Initial software version can be specified with forcever.
|
|
|
|
"""
|
2018-02-02 02:33:53 +00:00
|
|
|
dp = tcllib.argparser.DefaultParser(__file__, dpdesc)
|
2018-01-30 17:31:05 +00:00
|
|
|
dp.add_argument("forcever", help="Initial software version to check for OTA updates, e.g. AAM481", nargs="?", default=None)
|
|
|
|
dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
|
2017-10-10 20:25:38 +01:00
|
|
|
args = dp.parse_args(sys.argv[1:])
|
|
|
|
|
|
|
|
if args.forcever is not None:
|
|
|
|
force_ver_text = " from {}".format(args.forcever)
|
|
|
|
else:
|
|
|
|
force_ver_text = ""
|
2017-10-04 11:53:04 +01:00
|
|
|
|
2018-02-03 20:24:36 +00:00
|
|
|
prdcheck = "" if args.tocheck is None else args.tocheck
|
2017-10-31 15:41:06 +00:00
|
|
|
|
2017-12-19 23:01:55 +00:00
|
|
|
print("Loading list of devices.")
|
2018-02-05 15:32:26 +00:00
|
|
|
prds = devlist.get_devicelist()
|
2017-12-17 02:12:09 +00:00
|
|
|
|
2017-10-04 11:53:04 +01:00
|
|
|
print("List of latest OTA firmware{} by PRD:".format(force_ver_text))
|
2017-09-19 16:12:01 +01:00
|
|
|
|
2017-12-17 02:18:55 +00:00
|
|
|
for prd, variant in prds.items():
|
2018-02-03 20:24:36 +00:00
|
|
|
model = variant["variant"]
|
2017-12-17 02:18:55 +00:00
|
|
|
lastver = variant["last_ota"]
|
2018-02-03 20:24:36 +00:00
|
|
|
lastver = variant["last_full"] if lastver is None else lastver
|
2017-12-17 02:12:09 +00:00
|
|
|
if args.forcever is not None:
|
|
|
|
lastver = args.forcever
|
|
|
|
if prdcheck in prd:
|
|
|
|
try:
|
2018-02-07 00:22:09 +00:00
|
|
|
dev.curef = prd
|
|
|
|
dev.fwver = lastver
|
2018-02-07 00:49:44 +00:00
|
|
|
fc.reset_session(dev)
|
2018-02-07 00:22:09 +00:00
|
|
|
check_xml = fc.do_check(dev, max_tries=20)
|
2017-12-17 02:12:09 +00:00
|
|
|
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
2018-02-03 00:36:08 +00:00
|
|
|
versioninfo = ansi.YELLOW_DARK + fv + ansi.RESET + " ⇨ " + ansi.YELLOW + tv + ansi.RESET + " (FULL: {})".format(variant["last_full"])
|
2017-12-17 02:12:09 +00:00
|
|
|
print("{}: {} {} ({})".format(prd, versioninfo, fhash, model))
|
|
|
|
except RequestException as e:
|
|
|
|
print("{} ({}): {}".format(prd, lastver, str(e)))
|
|
|
|
continue
|
2017-11-12 21:19:04 +00:00
|
|
|
|
|
|
|
tcllib.FotaCheck.write_info_if_dumps_found()
|