2018-01-19 21:36:27 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# pylint: disable=C0111,C0326,C0103
|
|
|
|
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Query existence of missing OTAs."""
|
|
|
|
|
2018-01-19 21:36:27 +00:00
|
|
|
import json
|
2018-06-12 03:40:49 +01:00
|
|
|
import sys
|
2018-02-11 01:38:38 +00:00
|
|
|
|
2018-01-19 21:36:27 +00:00
|
|
|
import requests
|
|
|
|
|
2018-06-12 03:40:49 +01:00
|
|
|
from tcllib import argparser
|
2018-02-11 00:30:24 +00:00
|
|
|
from tcllib.devices import MobileDevice
|
2018-02-11 00:48:47 +00:00
|
|
|
from tcllib.dumpmgr import write_info_if_dumps_found
|
2018-02-11 01:38:38 +00:00
|
|
|
from tcllib.requests import CheckRequest, RequestRunner, ServerVoteSelector
|
2018-02-03 20:24:36 +00:00
|
|
|
|
|
|
|
|
2018-06-12 03:40:49 +01:00
|
|
|
dpdesc = """
|
|
|
|
Queries the database server for known versions and tries to find OTA files not yet in the database.
|
|
|
|
"""
|
|
|
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
|
|
|
args = dp.parse_args(sys.argv[1:])
|
|
|
|
del args
|
|
|
|
|
|
|
|
|
2018-01-19 21:36:27 +00:00
|
|
|
# 1. Fetch list of missing OTAs (e.g. from ancient versions to current)
|
|
|
|
# 2. Query updates from FOTA servers (and store XML)
|
|
|
|
# (3. Upload will be done manually with upload_logs.py)
|
|
|
|
|
|
|
|
|
|
|
|
print("Loading list of missing OTAs.")
|
|
|
|
versions_json = requests.get("https://tclota.birth-online.de/json_otaversions.php").text
|
|
|
|
versions = json.loads(versions_json)
|
|
|
|
num_versions = 0
|
|
|
|
for i in versions:
|
|
|
|
num_versions += versions[i]["num_missing"]
|
|
|
|
|
|
|
|
print("Got {} devices and a total of {} missing OTAs.".format(len(versions), num_versions))
|
|
|
|
|
2018-02-11 00:30:24 +00:00
|
|
|
dev = MobileDevice()
|
|
|
|
|
|
|
|
runner = RequestRunner(ServerVoteSelector())
|
|
|
|
runner.max_tries = 20
|
|
|
|
|
2018-01-19 21:36:27 +00:00
|
|
|
num_item = 1
|
|
|
|
for prd, data in versions.items():
|
|
|
|
print("{}:".format(prd), end="", flush=True)
|
|
|
|
for ver in data["missing_froms"]:
|
|
|
|
print(" {}".format(ver), end="", flush=True)
|
2018-02-11 00:30:24 +00:00
|
|
|
dev.curef = prd
|
|
|
|
dev.fwver = ver
|
|
|
|
chk = CheckRequest(dev)
|
|
|
|
runner.run(chk)
|
|
|
|
if chk.success:
|
2018-05-29 09:59:47 +01:00
|
|
|
if chk.result.tvver == data["latest_ota"]:
|
|
|
|
print("✔", end="", flush=True)
|
|
|
|
num_item += 1
|
|
|
|
elif chk.result.tvver in data["update_map"] and ver in data["update_map"][chk.result.tvver]:
|
|
|
|
# Delete dump as we already know the information
|
|
|
|
chk.result.delete_dump()
|
|
|
|
print("%", end="", flush=True)
|
|
|
|
else:
|
|
|
|
print("~", end="", flush=True)
|
2018-02-11 00:30:24 +00:00
|
|
|
else:
|
2018-01-19 21:36:27 +00:00
|
|
|
print("✖", end="", flush=True)
|
|
|
|
print("")
|
|
|
|
|
2018-02-11 00:30:24 +00:00
|
|
|
write_info_if_dumps_found()
|