tclcheck_allfull   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 39
dl 0
loc 61
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
# pylint: disable=C0111,C0326,C0103
5
6
"""Check all/given PRDs for FULL updates."""
7
8
import sys
9
10
from tcllib import ansi, argparser, devlist
11
from tcllib.devices import DesktopDevice
12
from tcllib.dumpmgr import write_info_if_dumps_found
13
from tcllib.requests import CheckRequest, RequestRunner, ServerVoteSelector
14
15
16
dev = DesktopDevice()
17
18
dpdesc = """
19
    Checks for the latest FULL updates for all PRD numbers or only for
20
    the PRD specified as prd.
21
    """
22
dp = argparser.DefaultParser(__file__, dpdesc)
23
dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
24
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)
25
args = dp.parse_args(sys.argv[1:])
26
27
prdcheck = "" if args.tocheck is None else args.tocheck
28
29
print("Loading list of devices.")
30
prds = devlist.get_devicelist(local=args.local)
31
32
print("List of latest FULL firmware by PRD:")
33
34
runner = RequestRunner(ServerVoteSelector())
35
runner.max_tries = 20
36
37
for prd, variant in prds.items():
38
    model = variant["variant"]
39
    lastver = variant["last_full"]
40
    if not prdcheck in prd:
41
        continue
42
    dev.curef = prd
43
    chk = CheckRequest(dev)
44
    runner.run(chk)
45
    if chk.success:
46
        result = chk.get_result()
47
        txt_tv = result.tvver
48
        if result.tvver != lastver:
49
            txt_tv = "{} (old: {} / OTA: {})".format(
50
                ansi.CYAN + txt_tv + ansi.RESET,
51
                ansi.CYAN_DARK + variant["last_full"] + ansi.RESET,
52
                variant["last_ota"]
53
            )
54
        else:
55
            result.delete_dump()
56
        print("{}: {} {} ({})".format(prd, txt_tv, result.filehash, model))
57
    else:
58
        print("{}: {}".format(prd, str(chk.error)))
59
60
write_info_if_dumps_found()
61