mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Download latest variants and versions from web service.
This commit is contained in:
parent
dfc52924e8
commit
e56599d3b4
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
/headers/
|
||||
/.nvimlog
|
||||
/header*.bin
|
||||
/prds.json
|
||||
|
66
prds.txt
66
prds.txt
@ -1,66 +0,0 @@
|
||||
PRD-63116-001 AAQ837 Unlocked BBB100-1 (USA)
|
||||
PRD-63116-003 AAR846 Bell BBB100-1
|
||||
PRD-63116-005 AAQ837 Rogers BBB100-1
|
||||
PRD-63116-007 AAQ302 Telus BBB100-1
|
||||
PRD-63116-009 AAQ837 BBB100-1 (HK)
|
||||
PRD-63116-010 AAN358 BBB100-1
|
||||
PRD-63116-013 AAQ837 BBB100-1
|
||||
PRD-63116-017 AAQ837 BBB100-1
|
||||
PRD-63116-020 AAQ837 BBB100-1
|
||||
PRD-63116-021 AAQ837 BBB100-1 (HK?)
|
||||
PRD-63116-023 AAQ837 BBB100-1
|
||||
PRD-63116-024 AAQ837 BBB100-1
|
||||
PRD-63116-027 AAP638 BBB100-1
|
||||
PRD-63116-029 AAQ837 BBB100-1
|
||||
PRD-63116-033 AAQ837 BBB100-1
|
||||
PRD-63116-036 AAN596 AT&T BBB100-1
|
||||
PRD-63116-039 AAS212 BBB100-1
|
||||
PRD-63116-040 AAQ302 BBB100-1
|
||||
PRD-63116-041 AAQ837 Black KEYone
|
||||
PRD-63116-042 AAQ837 Black KEYone
|
||||
PRD-63116-043 AAQ837 Black KEYone
|
||||
PRD-63116-044 AAQ837 BBB100-1
|
||||
PRD-63116-047 AAQ837 Black KEYone
|
||||
PRD-63116-051 AAQ302 Black KEYone
|
||||
PRD-63116-055 AAS426 Black KEYone
|
||||
PRD-63117-003 AAQ302 BBB100-2 (UK)
|
||||
PRD-63117-011 AAQ302 QWERTZ BBB100-2 (Germany)
|
||||
PRD-63117-015 AAQ302 BBB100-2 (NL, Belgium)
|
||||
PRD-63117-017 AAO472 BBB100-2
|
||||
PRD-63117-019 AAQ837 BBB100-2
|
||||
PRD-63117-021 AAQ837 BBB100-2
|
||||
PRD-63117-023 AAQ302 AZERTY BBB100-2 (Belgium)
|
||||
PRD-63117-025 AAQ302 BBB100-2
|
||||
PRD-63117-027 AAQ837 QWERTY BBB100-2 (UAE)
|
||||
PRD-63117-028 AAQ837 BBB100-2
|
||||
PRD-63117-029 AAQ302 BBB100-2
|
||||
PRD-63117-034 AAR970 BBB100-2
|
||||
PRD-63117-035 AAQ302 BBB100-2
|
||||
PRD-63117-036 AAQ302 BBB100-2
|
||||
PRD-63117-037 AAQ837 BBB100-2
|
||||
PRD-63117-039 AAQ302 BBB100-2
|
||||
PRD-63117-040 AAQ302 BBB100-2
|
||||
PRD-63117-041 AAQ302 BBB100-2
|
||||
PRD-63117-042 AAQ837 BBB100-2
|
||||
PRD-63117-043 AAQ837 BBB100-2
|
||||
PRD-63117-044 AAQ837 BBB100-2
|
||||
PRD-63117-047 AAQ302 BBB100-2
|
||||
PRD-63117-703 AAK199 Prerelease BBB100-2?
|
||||
PRD-63117-704 AAK199 Prerelease BBB100-2?
|
||||
PRD-63117-717 AAN358 Prerelease BBB100-2?
|
||||
PRD-63118-001 AAR108 Unlocked BBB100-3
|
||||
PRD-63118-003 AAR160 Sprint BBB100-3
|
||||
PRD-63734-001 AAS079 Unlocked BBB100-4
|
||||
PRD-63734-002 AAS079 Unlocked BBB100-4
|
||||
PRD-63734-003 AAS079 Unlocked BBB100-5
|
||||
PRD-63734-004 AAS079 Unlocked BBB100-5
|
||||
PRD-63737-003 AAQ667 BBD100-1
|
||||
PRD-63737-007 AAQ667 BBD100-1
|
||||
PRD-63737-009 AAQ667 BBD100-1
|
||||
PRD-63739-009 AAR748 BBD100-2
|
||||
PRD-63739-010 AAR748 BBD100-2
|
||||
PRD-63753-002 AAQ667 BBD100-6
|
||||
PRD-63753-003 AAQ667 BBD100-6
|
||||
PRD-63763-001 AAQ837 Unlocked BBB100-6
|
||||
PRD-63763-002 AAQ837 Unlocked Black BBB100-6
|
||||
PRD-63764-001 AAQ837 Unlocked BBB100-7
|
@ -24,24 +24,27 @@ fc.cltp = fc.CLTP.DESKTOP
|
||||
|
||||
prdcheck = "" if args.tocheck is None else args.tocheck
|
||||
|
||||
print("Loading list of devices...", end="", flush=True)
|
||||
prds = tcllib.FotaCheck.get_devicelist()
|
||||
print(" OK")
|
||||
|
||||
print("List of latest FULL firmware by PRD:")
|
||||
|
||||
with open("prds.txt", "rt") as f:
|
||||
for prdline in f:
|
||||
prdline = prdline.strip()
|
||||
prd, lastver, model = prdline.split(" ", 2)
|
||||
if prdcheck in prd:
|
||||
try:
|
||||
fc.reset_session()
|
||||
fc.curef = prd
|
||||
check_xml = fc.do_check(max_tries=20)
|
||||
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
||||
txt_tv = tv
|
||||
if tv != lastver:
|
||||
txt_tv = tcllib.ANSI_CYAN + txt_tv + tcllib.ANSI_RESET + " (OTA: {})".format(lastver)
|
||||
print("{}: {} {} ({})".format(prd, txt_tv, fhash, model))
|
||||
except RequestException as e:
|
||||
print("{}: {}".format(prd, str(e)))
|
||||
continue
|
||||
for prd in prds:
|
||||
model = prds[prd]["variant"]
|
||||
lastver = prds[prd]["last_full"]
|
||||
if prdcheck in prd:
|
||||
try:
|
||||
fc.reset_session()
|
||||
fc.curef = prd
|
||||
check_xml = fc.do_check(max_tries=20)
|
||||
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
||||
txt_tv = tv
|
||||
if tv != lastver:
|
||||
txt_tv = tcllib.ANSI_CYAN + txt_tv + tcllib.ANSI_RESET + " (OTA: {})".format(prds[prd]["last_ota"])
|
||||
print("{}: {} {} ({})".format(prd, txt_tv, fhash, model))
|
||||
except RequestException as e:
|
||||
print("{}: {}".format(prd, str(e)))
|
||||
continue
|
||||
|
||||
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
# pylint: disable=C0111,C0326,C0103
|
||||
|
||||
import json
|
||||
import requests
|
||||
import sys
|
||||
import tcllib
|
||||
from requests.exceptions import RequestException
|
||||
@ -27,25 +29,28 @@ else:
|
||||
|
||||
prdcheck = "" if args.tocheck is None else args.tocheck
|
||||
|
||||
print("Loading list of devices...", end="", flush=True)
|
||||
prds = tcllib.FotaCheck.get_devicelist()
|
||||
print(" OK")
|
||||
|
||||
print("List of latest OTA firmware{} by PRD:".format(force_ver_text))
|
||||
|
||||
with open("prds.txt", "r") as f:
|
||||
for prdline in f:
|
||||
prdline = prdline.strip()
|
||||
prd, lastver, model = prdline.split(" ", 2)
|
||||
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 = tcllib.ANSI_CYAN_DARK + fv + tcllib.ANSI_RESET + " ⇨ " + tcllib.ANSI_CYAN + tv + tcllib.ANSI_RESET
|
||||
print("{}: {} {} ({})".format(prd, versioninfo, fhash, model))
|
||||
except RequestException as e:
|
||||
print("{} ({}): {}".format(prd, lastver, str(e)))
|
||||
continue
|
||||
for prd in prds:
|
||||
model = prds[prd]["variant"]
|
||||
lastver = prds[prd]["last_ota"]
|
||||
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 = tcllib.ANSI_CYAN_DARK + fv + tcllib.ANSI_RESET + " ⇨ " + tcllib.ANSI_CYAN + tv + tcllib.ANSI_RESET + " (FULL: {})".format(prds[prd]["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()
|
||||
|
@ -31,16 +31,18 @@ if ceiling < floor:
|
||||
print("Invalid range!")
|
||||
raise SystemExit
|
||||
|
||||
print("Loading list of devices...", end="", flush=True)
|
||||
prd_db = tcllib.FotaCheck.get_devicelist()
|
||||
print(" OK")
|
||||
|
||||
print("Valid PRDs not already in database:")
|
||||
|
||||
with open("prds.txt", "r") as afile:
|
||||
prddict = collections.defaultdict(list)
|
||||
prda = afile.readlines()
|
||||
prds = [x.split(" ")[0].replace("PRD-", "").split("-") for x in prda]
|
||||
prdx = list({x[0]: x[1]} for x in prds)
|
||||
for prdc in prdx:
|
||||
for key, value in prdc.items():
|
||||
prddict[key].append(value)
|
||||
prds = [x.replace("PRD-", "").split("-") for x in prd_db]
|
||||
prdx = list({x[0]: x[1]} for x in prds)
|
||||
prddict = collections.defaultdict(list)
|
||||
for prdc in prdx:
|
||||
for key, value in prdc.items():
|
||||
prddict[key].append(value)
|
||||
|
||||
if args.tocheck is not None:
|
||||
args.tocheck = args.tocheck.replace("PRD-", "")
|
||||
|
25
tcllib.py
25
tcllib.py
@ -9,6 +9,7 @@ import enum
|
||||
import errno
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
@ -21,6 +22,10 @@ import numpy
|
||||
import requests
|
||||
from defusedxml import ElementTree
|
||||
|
||||
DEVICELIST_URL = "https://tclota.birth-online.de/json_lastupdates.php"
|
||||
DEVICELIST_FILE = "prds.json"
|
||||
DEVICELIST_CACHE_SECONDS = 86400
|
||||
|
||||
ANSI_UP_DEL = u"\u001b[F\u001b[K"
|
||||
ANSI_BLACK = u"\u001b[0;30m"
|
||||
ANSI_RED_DARK = u"\u001b[0;31m"
|
||||
@ -241,6 +246,26 @@ class FotaCheck:
|
||||
hexhash = engine.hexdigest()
|
||||
return hexhash
|
||||
|
||||
@staticmethod
|
||||
def get_devicelist():
|
||||
need_download = True
|
||||
try:
|
||||
filestat = os.stat(DEVICELIST_FILE)
|
||||
filemtime = filestat.st_mtime
|
||||
if filemtime > time.time() - DEVICELIST_CACHE_SECONDS:
|
||||
need_download = False
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
if need_download:
|
||||
prds_json = requests.get(DEVICELIST_URL).text
|
||||
with open(DEVICELIST_FILE, "wt") as df:
|
||||
df.write(prds_json)
|
||||
|
||||
with open(DEVICELIST_FILE, "rt") as df:
|
||||
prds = json.load(df)
|
||||
return prds
|
||||
|
||||
@staticmethod
|
||||
def get_creds():
|
||||
creds = {
|
||||
|
Loading…
Reference in New Issue
Block a user