2017-09-01 16:59:05 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# pylint: disable=C0111,C0326
|
|
|
|
|
|
|
|
import tcllib
|
2017-09-07 17:47:13 +01:00
|
|
|
from requests.exceptions import RequestException, Timeout
|
2017-09-01 16:59:05 +01:00
|
|
|
|
2017-09-23 21:17:57 +01:00
|
|
|
tcllib.make_escapes_work()
|
2017-09-13 00:40:19 +01:00
|
|
|
ANSI_UP_DEL = u"\u001b[F\u001b[K"
|
|
|
|
|
2017-09-01 16:59:05 +01:00
|
|
|
fc = tcllib.FotaCheck()
|
|
|
|
fc.serid = "3531510"
|
|
|
|
fc.fv = "AAM481"
|
|
|
|
#fc.osvs = "7.1.1"
|
2017-09-19 16:12:01 +01:00
|
|
|
fc.mode = fc.MODE_OTA
|
2017-09-12 20:40:40 +01:00
|
|
|
|
|
|
|
# CLTP = 10 (only show actual updates or HTTP 206) / 2010 (always show latest version for MODE_FULL)
|
2017-09-01 16:59:05 +01:00
|
|
|
fc.cltp = 10
|
|
|
|
|
2017-09-19 16:12:01 +01:00
|
|
|
print("List of latest OTA (from {}) firmware by PRD:".format(fc.fv))
|
2017-09-01 16:59:05 +01:00
|
|
|
|
|
|
|
with open("prds.txt", "r") as afile:
|
|
|
|
prdx = afile.read()
|
|
|
|
prds = list(filter(None, prdx.split("\n")))
|
2017-09-13 00:40:19 +01:00
|
|
|
|
|
|
|
while len(prds) > 0:
|
2017-09-19 16:12:01 +01:00
|
|
|
prd, lastver, model = prds[0].split(" ", 2)
|
2017-09-01 16:59:05 +01:00
|
|
|
try:
|
|
|
|
fc.reset_session()
|
|
|
|
fc.curef = prd
|
|
|
|
check_xml = fc.do_check()
|
|
|
|
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
2017-09-15 00:59:15 +01:00
|
|
|
txt_tv = tv
|
|
|
|
if fc.mode == fc.MODE_OTA:
|
|
|
|
txt_tv = "{} ⇨ {}".format(fv, tv)
|
|
|
|
print("{}: {} {} ({})".format(prd, txt_tv, fhash, model))
|
2017-09-13 00:40:19 +01:00
|
|
|
prds.pop(0)
|
2017-09-07 17:47:13 +01:00
|
|
|
except Timeout as e:
|
|
|
|
print("{} failed. (Connection timed out.)".format(prd))
|
2017-09-13 00:40:19 +01:00
|
|
|
print(ANSI_UP_DEL, end="")
|
2017-09-07 17:47:13 +01:00
|
|
|
continue
|
2017-09-01 17:34:15 +01:00
|
|
|
except (SystemExit, RequestException) as e:
|
|
|
|
print("{} failed. ({})".format(prd, str(e)))
|
2017-09-13 00:40:19 +01:00
|
|
|
if e.response.status_code in [204, 404]:
|
|
|
|
# No update available or invalid request - remove from queue
|
|
|
|
prds.pop(0)
|
|
|
|
else:
|
|
|
|
print(ANSI_UP_DEL, end="")
|
2017-09-01 16:59:05 +01:00
|
|
|
continue
|