1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-09-19 22:33:25 +01:00
This commit is contained in:
Markus Birth 2018-02-10 02:37:10 +01:00
parent 57f3f87f70
commit 485e7b30b8
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
5 changed files with 34 additions and 47 deletions

View File

@ -7,9 +7,7 @@
import sys import sys
import tcllib from tcllib import ansi, argparser, devlist
import tcllib.argparser
from tcllib import ansi, devlist
from tcllib.devices import DesktopDevice from tcllib.devices import DesktopDevice
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, write_info_if_dumps_found from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, write_info_if_dumps_found
@ -20,7 +18,7 @@ dpdesc = """
Checks for the latest FULL updates for all PRD numbers or only for Checks for the latest FULL updates for all PRD numbers or only for
the PRD specified as prd. the PRD specified as prd.
""" """
dp = tcllib.argparser.DefaultParser(__file__, dpdesc) dp = argparser.DefaultParser(__file__, dpdesc)
dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD") dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False) dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])

View File

@ -7,9 +7,7 @@
import sys import sys
import tcllib from tcllib import ansi, argparser, devlist
import tcllib.argparser
from tcllib import ansi, devlist
from tcllib.devices import MobileDevice from tcllib.devices import MobileDevice
from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, write_info_if_dumps_found from tcllib.requests import RequestRunner, CheckRequest, ServerVoteSelector, write_info_if_dumps_found
@ -20,7 +18,7 @@ dpdesc = """
Checks for the latest OTA updates for all PRD numbers or only for the PRD specified Checks for the latest OTA updates for all PRD numbers or only for the PRD specified
as prd. Initial software version can be specified with forcever. as prd. Initial software version can be specified with forcever.
""" """
dp = tcllib.argparser.DefaultParser(__file__, dpdesc) dp = argparser.DefaultParser(__file__, dpdesc)
dp.add_argument("forcever", help="Initial software version to check for OTA updates, e.g. AAM481", nargs="?", default=None) dp.add_argument("forcever", help="Initial software version to check for OTA updates, e.g. AAM481", nargs="?", default=None)
dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD") dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False) dp.add_argument("-l", "--local", help="Force using local database", dest="local", action="store_true", default=False)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from .tcl import * from .checkrequest import CheckRequest
from .runner import * from .runner import *
from .serverselector import * from .serverselector import *
from .dumpmgr import write_info_if_dumps_found from .dumpmgr import write_info_if_dumps_found

View File

@ -1,31 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from .. import devices
from . import tclresult
from collections import OrderedDict from collections import OrderedDict
from defusedxml import ElementTree from .. import devices
from .tclrequest import TclRequest
class TclRequest: from .tclresult import CheckResult
def __init__(self):
self.uri = ""
self.response = None
self.result = None
self.error = None
self.success = False
def get_headers(self):
return {}
def get_params(self):
return {}
def is_done(self, http_status: int, contents: str):
"""Checks if query is done or needs retry."""
return False
def get_result(self):
"""Returns Result object."""
return self.result
class CheckRequest(TclRequest): class CheckRequest(TclRequest):
def __init__(self, device: devices.Device): def __init__(self, device: devices.Device):
@ -59,7 +37,7 @@ class CheckRequest(TclRequest):
} }
if http_status == 200: if http_status == 200:
self.response = contents self.response = contents
self.result = tclresult.CheckResult(contents) self.result = CheckResult(contents)
self.success = True self.success = True
return True return True
elif http_status in ok_states: elif http_status in ok_states:
@ -79,15 +57,3 @@ class CheckRequest(TclRequest):
# 2. HTTP 204 - means: no newer update available # 2. HTTP 204 - means: no newer update available
# 3. HTTP 404 - means: invalid device or firmware version # 3. HTTP 404 - means: invalid device or firmware version
# 4. anything else: server problem (esp. 500, 502, 503) # 4. anything else: server problem (esp. 500, 502, 503)
class DownloadRequest(TclRequest):
def __init__(self, device: devices.Device):
super().__init__()
self.uri = "/download_request.php"
self.method = "POST"
self.device = device
def get_headers(self):
return {"User-Agent": self.device.ua}

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from . import tclresult
class TclRequest:
def __init__(self):
self.uri = ""
self.response = None
self.result = None
self.error = None
self.success = False
def get_headers(self):
return {}
def get_params(self):
return {}
def is_done(self, http_status: int, contents: str):
"""Checks if query is done or needs retry."""
return False
def get_result(self) -> tclresult.TclResult:
"""Returns Result object."""
return self.result