1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-09-19 22:33:25 +01:00

first crack at do_check

This commit is contained in:
thurask 2018-02-05 19:11:56 -05:00
parent 58a270275d
commit 86e01c1e33
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048

View File

@ -14,8 +14,8 @@ from defusedxml import ElementTree
class TclCheckMixin:
"""A mixin component for TCL's update request API."""
def do_check(self, device=None, https=True, timeout=10, max_tries=5):
"""Perform update request with given parameters."""
def prep_check(self, device=None, https=True):
"""Prepare URL and parameters for update request."""
protocol = "https://" if https else "http://"
url = protocol + self.g2master + "/check.php"
params = OrderedDict()
@ -44,7 +44,11 @@ class TclCheckMixin:
params["chnl"] = self.chnl.value
#params["osvs"] = self.osvs
#params["ckot"] = self.ckot.value
return url, params
def do_check(self, device=None, https=True, timeout=10, max_tries=5):
"""Perform update request with given parameters."""
url, params = self.prep_check(device, https)
last_response = None
for _ in range(0, max_tries):
try: