1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-09-19 22:33:25 +01:00
tcl_ota_check/tclcheck_allota.py

65 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
from requests.exceptions import RequestException
import tcllib
2018-02-02 02:33:53 +00:00
import tcllib.argparser
from tcllib import ansi
from tcllib import devlist
2018-02-03 20:24:36 +00:00
fc = tcllib.FotaCheck()
fc.serid = "3531510"
2018-02-03 20:24:36 +00:00
#fc.osvs = "7.1.1"
2017-10-15 00:51:38 +01:00
fc.mode = fc.MODE.OTA
2018-02-03 20:24:36 +00:00
fc.cltp = fc.CLTP.MOBILE
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)
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 = ""
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.")
prds = devlist.get_devicelist()
print("List of latest OTA firmware{} by PRD:".format(force_ver_text))
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
if prdcheck in prd:
try:
fc.reset_session()
fc.curef = prd
fc.fv = lastver
check_xml = fc.do_check(max_tries=20)
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
versioninfo = ansi.YELLOW_DARK + fv + ansi.RESET + "" + ansi.YELLOW + tv + ansi.RESET + " (FULL: {})".format(variant["last_full"])
print("{}: {} {} ({})".format(prd, versioninfo, fhash, model))
except RequestException as e:
print("{} ({}): {}".format(prd, lastver, str(e)))
continue
tcllib.FotaCheck.write_info_if_dumps_found()