1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-10 06:16:46 +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
import tcllib.argparser import tcllib.argparser
from tcllib import ansi from tcllib import ansi, devlist
from tcllib import devlist
from tcllib.devices import DesktopDevice from tcllib.devices import DesktopDevice

View File

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

View File

@ -12,8 +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, devlist
from tcllib import devlist
fc = tcllib.FotaCheck() fc = tcllib.FotaCheck()

View File

@ -11,8 +11,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, devlist
from tcllib import devlist
# Variants to scan for # Variants to scan for

View File

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

View File

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

View File

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