1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-09 22:06:47 +00:00

docstrings, import sorting

This commit is contained in:
thurask 2018-02-05 19:03:25 -05:00
parent 808282c347
commit 58a270275d
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048
7 changed files with 20 additions and 15 deletions

View File

@ -11,8 +11,7 @@ from requests.exceptions import RequestException
import tcllib
import tcllib.argparser
from tcllib import ansi
from tcllib import devlist
from tcllib import ansi, devlist
from tcllib.devices import DesktopDevice

View File

@ -11,8 +11,7 @@ from requests.exceptions import RequestException
import tcllib
import tcllib.argparser
from tcllib import ansi
from tcllib import devlist
from tcllib import ansi, devlist
fc = tcllib.FotaCheck()

View File

@ -12,8 +12,7 @@ from requests.exceptions import RequestException, Timeout
import tcllib
import tcllib.argparser
from tcllib import ansi
from tcllib import devlist
from tcllib import ansi, devlist
fc = tcllib.FotaCheck()

View File

@ -11,8 +11,7 @@ from requests.exceptions import RequestException, Timeout
import tcllib
import tcllib.argparser
from tcllib import ansi
from tcllib import devlist
from tcllib import ansi, devlist
# Variants to scan for

View File

@ -9,8 +9,8 @@ import enum
import requests
from . import (dumpmgr, servervote, tclcheck,
tclchecksum, tclencheader, tclrequest)
from . import (dumpmgr, servervote, tclcheck, tclchecksum, tclencheader,
tclrequest)
def default_enum(enumname, vardict, qualroot="tcllib.FotaCheck"):

View File

@ -3,6 +3,7 @@
"""Pseudo-devices for desktop/mobile requests"""
class Device():
"""Generic pseudo-device class."""
CLTP_STATES = {
"MOBILE": 10, # only show actual newer versions or HTTP 206
"DESKTOP": 2010, # always show latest version for FULL updates
@ -13,6 +14,7 @@ class Device():
CKOT_STATES = {"ALL": 1, "AOTA_ONLY": 2, "FOTA_ONLY": 3}
def __init__(self, curef, fwver):
"""Populate variables."""
self.curef = curef
self.imei = ""
self.osver = "7.1.1"
@ -27,35 +29,39 @@ class Device():
self.ua = "tcl"
def is_rooted(self):
return (self.rtd == 1)
"""Get RTD as boolean."""
return self.rtd == 1
def set_rooted(self, new_state: bool):
if new_state:
self.rtd = 1
else:
self.rtd = 0
"""Set RTD as integer."""
self.rtd = int(new_state)
def set_cltp(self, new_cltp: str):
"""Set CLTP while handling non-numeric input."""
# (Numerical CLTPs can be set by direct assigns.)
# Throws exception when invalid cltp given:
self.cltp = self.CLTP_STATES[new_cltp]
def set_mode(self, new_mode: str):
"""Set MODE while handling non-numeric input."""
# (Numerical MODEs can be set by direct assigns.)
# Throws exception when invalid mode given:
self.mode = self.MODE_STATES[new_mode]
def set_chnl(self, new_chnl: str):
"""Set CHNL while handling non-numeric input."""
# (Numerical CHNLs can be set by direct assigns.)
# Throws exception when invalid mode given:
self.chnl = self.CHNL_STATES[new_chnl]
def set_ckot(self, new_ckot: str):
"""Set CKOT while handling non-numeric input."""
# (Numerical CKOTs can be set by direct assigns.)
# Throws exception when invalid mode given:
self.ckot = self.CKOT_STATES[new_ckot]
class MobileDevice(Device):
"""Generic mobile (i.e. OTA) device."""
def __init__(self, curef="PRD-63117-011", fwver="AAO472"):
super().__init__(curef, fwver)
self.imei = "3531510"
@ -64,6 +70,7 @@ class MobileDevice(Device):
self.ua = "com.tcl.fota/5.1.0.2.0029.0, Android"
class DesktopDevice(Device):
"""Generic desktop (i.e. full) device."""
def __init__(self, curef="PRD-63117-011", fwver="AAA000"):
super().__init__(curef, fwver)
self.imei = "543212345000000"

View File

@ -8,8 +8,10 @@
import json
from defusedxml import ElementTree
from . import credentials
class TclChecksumMixin:
"""A mixin component for TCL's checksum API."""
def do_checksum(self, encslave, address, uri):