|
1
|
|
|
#!/usr/bin/env python3 |
|
2
|
|
|
# -*- coding: utf-8 -*- |
|
3
|
|
|
|
|
4
|
|
|
# pylint: disable=C0111,C0326,C0103 |
|
5
|
|
|
|
|
6
|
|
|
"""Query existence of missing OTAs.""" |
|
7
|
|
|
|
|
8
|
|
|
import json |
|
9
|
|
|
import sys |
|
10
|
|
|
|
|
11
|
|
|
import requests |
|
12
|
|
|
|
|
13
|
|
|
from tcllib import argparser |
|
14
|
|
|
from tcllib.devices import MobileDevice |
|
15
|
|
|
from tcllib.dumpmgr import write_info_if_dumps_found |
|
16
|
|
|
from tcllib.requests import CheckRequest, RequestRunner, ServerVoteSelector |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
dpdesc = """ |
|
20
|
|
|
Queries the database server for known versions and tries to find OTA files not yet in the database. |
|
21
|
|
|
""" |
|
22
|
|
|
dp = argparser.DefaultParser(__file__, dpdesc) |
|
23
|
|
|
args = dp.parse_args(sys.argv[1:]) |
|
24
|
|
|
del args |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
# 1. Fetch list of missing OTAs (e.g. from ancient versions to current) |
|
28
|
|
|
# 2. Query updates from FOTA servers (and store XML) |
|
29
|
|
|
# (3. Upload will be done manually with upload_logs.py) |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
print("Loading list of missing OTAs.") |
|
33
|
|
|
versions_json = requests.get("https://tclota.birth-online.de/json_otaversions.php").text |
|
34
|
|
|
versions = json.loads(versions_json) |
|
35
|
|
|
num_versions = 0 |
|
36
|
|
|
for i in versions: |
|
37
|
|
|
num_versions += versions[i]["num_missing"] |
|
38
|
|
|
|
|
39
|
|
|
print("Got {} devices and a total of {} missing OTAs.".format(len(versions), num_versions)) |
|
40
|
|
|
|
|
41
|
|
|
dev = MobileDevice() |
|
42
|
|
|
|
|
43
|
|
|
runner = RequestRunner(ServerVoteSelector()) |
|
44
|
|
|
runner.max_tries = 20 |
|
45
|
|
|
|
|
46
|
|
|
num_item = 1 |
|
47
|
|
|
for prd, data in versions.items(): |
|
48
|
|
|
print("{}:".format(prd), end="", flush=True) |
|
49
|
|
|
for ver in data["missing_froms"]: |
|
50
|
|
|
print(" {}".format(ver), end="", flush=True) |
|
51
|
|
|
dev.curef = prd |
|
52
|
|
|
dev.fwver = ver |
|
53
|
|
|
chk = CheckRequest(dev) |
|
54
|
|
|
runner.run(chk) |
|
55
|
|
|
if chk.success: |
|
56
|
|
|
if chk.result.tvver == data["latest_ota"]: |
|
57
|
|
|
print("✔", end="", flush=True) |
|
58
|
|
|
num_item += 1 |
|
59
|
|
|
elif chk.result.tvver in data["update_map"] and ver in data["update_map"][chk.result.tvver]: |
|
60
|
|
|
# Delete dump as we already know the information |
|
61
|
|
|
chk.result.delete_dump() |
|
62
|
|
|
print("%", end="", flush=True) |
|
63
|
|
|
else: |
|
64
|
|
|
print("~", end="", flush=True) |
|
65
|
|
|
else: |
|
66
|
|
|
print("✖", end="", flush=True) |
|
67
|
|
|
print("") |
|
68
|
|
|
|
|
69
|
|
|
write_info_if_dumps_found() |
|
70
|
|
|
|