1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-10 06:16:46 +00:00

Turned DevListMixin into namespaced methods.

This commit is contained in:
Markus Birth 2018-02-05 16:32:26 +01:00
parent 0262c67531
commit 7332846805
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
6 changed files with 55 additions and 56 deletions

View File

@ -12,6 +12,7 @@ from requests.exceptions import RequestException
import tcllib import tcllib
import tcllib.argparser import tcllib.argparser
from tcllib import ansi from tcllib import ansi
from tcllib import devlist
fc = tcllib.FotaCheck() fc = tcllib.FotaCheck()
@ -34,7 +35,7 @@ fc.cltp = fc.CLTP.DESKTOP
prdcheck = "" if args.tocheck is None else args.tocheck prdcheck = "" if args.tocheck is None else args.tocheck
print("Loading list of devices.") print("Loading list of devices.")
prds = tcllib.FotaCheck.get_devicelist() prds = devlist.get_devicelist()
print("List of latest FULL firmware by PRD:") print("List of latest FULL firmware by PRD:")

View File

@ -12,6 +12,7 @@ from requests.exceptions import RequestException
import tcllib import tcllib
import tcllib.argparser import tcllib.argparser
from tcllib import ansi from tcllib import ansi
from tcllib import devlist
fc = tcllib.FotaCheck() fc = tcllib.FotaCheck()
@ -37,7 +38,7 @@ else:
prdcheck = "" if args.tocheck is None else args.tocheck prdcheck = "" if args.tocheck is None else args.tocheck
print("Loading list of devices.") print("Loading list of devices.")
prds = tcllib.FotaCheck.get_devicelist() prds = devlist.get_devicelist()
print("List of latest OTA firmware{} by PRD:".format(force_ver_text)) print("List of latest OTA firmware{} by PRD:".format(force_ver_text))

View File

@ -13,6 +13,7 @@ from requests.exceptions import RequestException, Timeout
import tcllib import tcllib
import tcllib.argparser import tcllib.argparser
from tcllib import ansi from tcllib import ansi
from tcllib import devlist
fc = tcllib.FotaCheck() fc = tcllib.FotaCheck()
@ -41,7 +42,7 @@ if ceiling < floor:
raise SystemExit raise SystemExit
print("Loading list of devices...", end="", flush=True) print("Loading list of devices...", end="", flush=True)
prd_db = tcllib.FotaCheck.get_devicelist() prd_db = devlist.get_devicelist()
print(" OK") print(" OK")
print("Valid PRDs not already in database:") print("Valid PRDs not already in database:")

View File

@ -12,6 +12,7 @@ from requests.exceptions import RequestException, Timeout
import tcllib import tcllib
import tcllib.argparser import tcllib.argparser
from tcllib import ansi from tcllib import ansi
from tcllib import devlist
# Variants to scan for # Variants to scan for
@ -42,7 +43,7 @@ if ceiling < floor:
raise SystemExit raise SystemExit
print("Loading list of known devices...", end="", flush=True) print("Loading list of known devices...", end="", flush=True)
prd_db = tcllib.FotaCheck.get_devicelist() prd_db = devlist.get_devicelist()
print(" OK") print(" OK")
print("Valid PRDs not already in database:") print("Valid PRDs not already in database:")

View File

@ -25,7 +25,6 @@ class FotaCheck(
tclencheader.TclEncHeaderMixin, tclencheader.TclEncHeaderMixin,
servervote.ServerVoteMixin, servervote.ServerVoteMixin,
credentials.CredentialsMixin, credentials.CredentialsMixin,
devlist.DevListMixin,
dumpmgr.DumpMgrMixin dumpmgr.DumpMgrMixin
): ):
"""Main API handler class.""" """Main API handler class."""

View File

@ -19,9 +19,6 @@ DEVICELIST_FILE = "prds.json"
DEVICELIST_CACHE_SECONDS = 86400 DEVICELIST_CACHE_SECONDS = 86400
class DevListMixin:
"""A mixin component for device list management."""
@staticmethod
def get_devicelist(force=False, output_diff=True): def get_devicelist(force=False, output_diff=True):
"""Return device list from saved database.""" """Return device list from saved database."""
need_download = True need_download = True
@ -46,11 +43,10 @@ class DevListMixin:
prds = json.load(dlfile) prds = json.load(dlfile)
if old_prds and output_diff: if old_prds and output_diff:
DevListMixin.print_prd_diff(old_prds, prds) print_prd_diff(old_prds, prds)
return prds return prds
@staticmethod
def print_prd_diff(old_prds, new_prds): def print_prd_diff(old_prds, new_prds):
"""Print changes between old and new databases.""" """Print changes between old and new databases."""
added_prds = [prd for prd in new_prds if prd not in old_prds] added_prds = [prd for prd in new_prds if prd not in old_prds]