Completed
Branch master (470cbf)
by John
01:11
created

tcldelta_main()   A

Complexity

Conditions 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 1
c 1
b 1
f 1
dl 0
loc 14
rs 9.4285
1
#!/usr/bin/env python3
2
"""Grab latest delta update for TCL API devices."""
3
4
import sys  # load arguments
5
from bbarchivist import scriptutils  # default parser
6
7
__author__ = "Thurask"
8
__license__ = "WTFPL v2"
9
__copyright__ = "2017 Thurask"
10
11
12
def grab_args():
13
    """
14
    Parse arguments from argparse/questionnaire.
15
16
    Invoke a function with those arguments.
17
    """
18
    parser = scriptutils.default_parser("bb-tcldelta", "Check for delta updates for TCL devices")
19
    parser.add_argument("curef", help="PRD to check")
20
    parser.add_argument("fvver", help="Current OS version")
21
    parser.add_argument(
22
        "-d",
23
        "--download",
24
        dest="download",
25
        help="Download update file",
26
        action="store_true",
27
        default=False)
28
    args = parser.parse_args(sys.argv[1:])
29
    parser.set_defaults()
30
    tcldelta_main(args.curef, args.fvver, args.download)
31
32
33
def tcldelta_main(curef, fvver, download=False):
34
    """
35
    Scan one PRD and produce download URL and filename.
36
37
    :param curef: PRD of the phone variant to check.
38
    :type curef: str
39
40
    :param fvver: Current firmware version.
41
    :type fvver: str
42
43
    :param download: If we'll download the file that this returns. Default is False.
44
    :type download: bool
45
    """
46
    scriptutils.tcl_prd_scan(curef, download, mode=2, fvver=fvver)
47
48
49
if __name__ == "__main__":
50
    grab_args()
51