|
1
|
|
|
#!/usr/bin/env python3 |
|
2
|
|
|
"""Grab latest delta update for TCL API devices.""" |
|
3
|
|
|
|
|
4
|
|
|
import sys # load arguments |
|
5
|
|
|
|
|
6
|
|
|
from bbarchivist import decorators # enter to exit |
|
7
|
|
|
from bbarchivist import scriptutils # default parser |
|
8
|
|
|
|
|
9
|
|
|
__author__ = "Thurask" |
|
10
|
|
|
__license__ = "WTFPL v2" |
|
11
|
|
|
__copyright__ = "2017-2018 Thurask" |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
View Code Duplication |
def grab_args(): |
|
|
|
|
|
|
15
|
|
|
""" |
|
16
|
|
|
Parse arguments from argparse/questionnaire. |
|
17
|
|
|
|
|
18
|
|
|
Invoke a function with those arguments. |
|
19
|
|
|
""" |
|
20
|
|
|
parser = scriptutils.default_parser("bb-tcldelta", "Check for delta updates for TCL devices") |
|
21
|
|
|
parser.add_argument("curef", help="PRD to check", default=None, nargs="?") |
|
22
|
|
|
parser.add_argument("fvver", help="Current OS version", default=None, nargs="?") |
|
23
|
|
|
parser.add_argument( |
|
24
|
|
|
"-d", |
|
25
|
|
|
"--download", |
|
26
|
|
|
dest="download", |
|
27
|
|
|
help="Download update file", |
|
28
|
|
|
action="store_true", |
|
29
|
|
|
default=False) |
|
30
|
|
|
parser.add_argument( |
|
31
|
|
|
"-o", |
|
32
|
|
|
"--original-filename", |
|
33
|
|
|
dest="original", |
|
34
|
|
|
help="Save with original filename (implies -d)", |
|
35
|
|
|
action="store_true", |
|
36
|
|
|
default=False) |
|
37
|
|
|
parser.add_argument( |
|
38
|
|
|
"-r", |
|
39
|
|
|
"--remote", |
|
40
|
|
|
dest="remote", |
|
41
|
|
|
help="Get latest OTA versions from remote server", |
|
42
|
|
|
action="store_true", |
|
43
|
|
|
default=False) |
|
44
|
|
|
parser.add_argument( |
|
45
|
|
|
"-x", |
|
46
|
|
|
"--export", |
|
47
|
|
|
dest="export", |
|
48
|
|
|
help="Write XML to logs folder", |
|
49
|
|
|
action="store_true", |
|
50
|
|
|
default=False) |
|
51
|
|
|
args = parser.parse_args(sys.argv[1:]) |
|
52
|
|
|
parser.set_defaults() |
|
53
|
|
|
if args.curef is None: |
|
54
|
|
|
args = questionnaire(args) |
|
55
|
|
|
elif args.fvver is None and not args.remote: |
|
56
|
|
|
args = questionnaire(args) |
|
57
|
|
|
tcldelta_main(args.curef, args.fvver, args.download, args.original, args.export) |
|
58
|
|
|
decorators.enter_to_exit(True) |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
def questionnaire(args): |
|
62
|
|
|
""" |
|
63
|
|
|
Clear up missing arguments. |
|
64
|
|
|
|
|
65
|
|
|
:param args: Arguments. |
|
66
|
|
|
:type args: argparse.Namespace |
|
67
|
|
|
""" |
|
68
|
|
|
if args.curef is None: |
|
69
|
|
|
args.curef = input("CUREF: ") |
|
70
|
|
|
if args.fvver is None: |
|
71
|
|
|
args.fvver = input("STARTING OS: ") |
|
72
|
|
|
return args |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
def tcldelta_main(curef, fvver, download=False, original=False, export=False, remote=False): |
|
76
|
|
|
""" |
|
77
|
|
|
Scan one PRD and produce download URL and filename. |
|
78
|
|
|
|
|
79
|
|
|
:param curef: PRD of the phone variant to check. |
|
80
|
|
|
:type curef: str |
|
81
|
|
|
|
|
82
|
|
|
:param fvver: Current firmware version. |
|
83
|
|
|
:type fvver: str |
|
84
|
|
|
|
|
85
|
|
|
:param download: If we'll download the file that this returns. Default is False. |
|
86
|
|
|
:type download: bool |
|
87
|
|
|
|
|
88
|
|
|
:param original: If we'll download the file with its original filename instead of delta-safe. Default is False. |
|
89
|
|
|
:type original: bool |
|
90
|
|
|
|
|
91
|
|
|
:param export: Whether to export XML response to file. Default is False. |
|
92
|
|
|
:type export: bool |
|
93
|
|
|
|
|
94
|
|
|
:param remote: Whether to get OTA version from remote server. Default is False. |
|
95
|
|
|
:type remote: bool |
|
96
|
|
|
""" |
|
97
|
|
|
if remote: |
|
98
|
|
|
fvver = scriptutils.tcl_delta_remote(curef) |
|
99
|
|
|
scriptutils.tcl_prd_scan(curef, download, mode=2, fvver=fvver, original=original, export=export) |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
if __name__ == "__main__": |
|
103
|
|
|
grab_args() |
|
104
|
|
|
|