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

Rearrange storing of result object.

This commit is contained in:
Markus Birth 2018-02-09 00:12:46 +01:00
parent 1297b31b2e
commit d2c51e70d5
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A

View File

@ -8,6 +8,7 @@ from defusedxml import ElementTree
class TclRequest:
def __init__(self):
self.uri = ""
self.response = None
self.result = None
self.error = None
self.success = False
@ -24,7 +25,7 @@ class TclRequest:
def get_result(self):
"""Returns Result object."""
return None
return self.result
class CheckRequest(TclRequest):
def __init__(self, device: devices.Device):
@ -57,7 +58,8 @@ class CheckRequest(TclRequest):
404: "No data for requested CUREF/FV combination.",
}
if http_status == 200:
self.result = contents
self.response = contents
self.result = tclresult.CheckResult(contents)
self.success = True
return True
elif http_status in ok_states:
@ -72,11 +74,6 @@ class CheckRequest(TclRequest):
return True
return False
def get_result(self):
if not self.success:
return None
return tclresult.CheckResult(self.result)
# Check requests have 4 possible outcomes:
# 1. HTTP 200 with XML data - our desired info
# 2. HTTP 204 - means: no newer update available