1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-09 22:06:47 +00:00
tcl_ota_check/tclcheck_allota.py

63 lines
2.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable=C0111,C0326,C0103
2018-02-03 21:25:26 +00:00
"""Check all/given PRDs for OTA updates."""
import sys
2018-02-03 20:24:36 +00:00
2018-02-10 01:37:10 +00:00
from tcllib import ansi, argparser, devlist
2018-02-07 00:22:09 +00:00
from tcllib.devices import MobileDevice
2018-02-11 00:48:47 +00:00
from tcllib.dumpmgr import write_info_if_dumps_found
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector
2018-02-03 20:24:36 +00:00
2018-02-07 00:22:09 +00:00
dev = MobileDevice()
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-10 01:37:10 +00:00
dp = argparser.DefaultParser(__file__, dpdesc)
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")
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)
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 = ""
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
print("Loading list of devices.")
2018-02-09 20:41:12 +00:00
prds = devlist.get_devicelist(local=args.local)
print("List of latest OTA firmware{} by PRD:".format(force_ver_text))
2018-02-08 00:15:58 +00:00
runner = RequestRunner(ServerVoteSelector())
runner.max_tries = 20
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
if args.forcever is not None:
lastver = args.forcever
2018-02-08 00:15:58 +00:00
if not prdcheck in prd:
continue
dev.curef = prd
dev.fwver = lastver
chk = CheckRequest(dev)
runner.run(chk)
if chk.success:
result = chk.get_result()
versioninfo = ansi.YELLOW_DARK + result.fvver + ansi.RESET + "" + ansi.YELLOW + result.tvver + ansi.RESET + " (FULL: {})".format(variant["last_full"])
print("{}: {} {} ({})".format(prd, versioninfo, result.filehash, model))
else:
print("{} ({}): {}".format(prd, lastver, chk.error))
2018-02-08 23:17:08 +00:00
write_info_if_dumps_found()