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

document all args, describe all parsers, add db shortcut

This commit is contained in:
thurask 2018-01-30 12:31:05 -05:00
parent f0bdc0af75
commit f7ddf22d2d
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048
8 changed files with 54 additions and 24 deletions

View File

@ -12,18 +12,18 @@ fc = tcllib.FotaCheck()
fc.serid = "3531510" fc.serid = "3531510"
#fc.osvs = "7.1.1" #fc.osvs = "7.1.1"
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.description = """
Checks for the latest FULL updates for the specified PRD number or for an OTA from the Checks for the latest FULL updates for the specified PRD number or for an OTA from the
version specified as fvver. version specified as fvver.
""" """
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("prd", nargs=1, help="CU Reference #, e.g. PRD-63117-011") dp.add_argument("prd", nargs=1, help="CU Reference #, e.g. PRD-63117-011")
dp.add_argument("fvver", nargs="?", help="Firmware version to check for OTA updates, e.g. AAM481 (omit to run FULL check)", default="AAA000") dp.add_argument("fvver", nargs="?", help="Firmware version to check for OTA updates, e.g. AAM481 (omit to run FULL check)", default="AAA000")
dp.add_argument("-i", "--imei", help="use specified IMEI instead of default", type=str) dp.add_argument("-i", "--imei", help="use specified IMEI instead of default", type=str)
dp.add_argument("-m", "--mode", help="force type of update to check for", default="auto", type=str ,choices=["full", "ota"]) dp.add_argument("-m", "--mode", help="force type of update to check for", default="auto", type=str ,choices=["full", "ota"])
dp.add_argument("-t", "--type", help="force type of check to run", default="auto", type=str, choices=["desktop", "mobile"]) dp.add_argument("-t", "--type", help="force type of check to run", default="auto", type=str, choices=["desktop", "mobile"])
dp.add_argument("--rawmode", help="override --mode with raw value (2=OTA, 4=FULL)") dp.add_argument("--rawmode", help="override --mode with raw value (2=OTA, 4=FULL)", metavar="MODE")
dp.add_argument("--rawcltp", help="override --type with raw value (10=MOBILE, 2010=DESKTOP)") dp.add_argument("--rawcltp", help="override --type with raw value (10=MOBILE, 2010=DESKTOP)", metavar="CLTP")
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
def sel_mode(txtmode, autoval, rawval): def sel_mode(txtmode, autoval, rawval):

View File

@ -14,8 +14,12 @@ fc.serid = "3531510"
fc.fv = "AAA000" fc.fv = "AAA000"
fc.mode = fc.MODE.FULL fc.mode = fc.MODE.FULL
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.add_argument("-p", "--prd", dest="tocheck", nargs="?", default=None) Checks for the latest FULL updates for all PRD numbers or only for
the PRD specified as prd.
"""
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
# CLTP = 10 (only show actual updates or HTTP 206) / 2010 (always show latest version for MODE.FULL) # CLTP = 10 (only show actual updates or HTTP 206) / 2010 (always show latest version for MODE.FULL)

View File

@ -17,9 +17,13 @@ fc.serid = "3531510"
fc.mode = fc.MODE.OTA fc.mode = fc.MODE.OTA
fc.cltp = fc.CLTP.MOBILE fc.cltp = fc.CLTP.MOBILE
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.add_argument("forcever", nargs="?", default=None) Checks for the latest OTA updates for all PRD numbers or only for the PRD specified
dp.add_argument("-p", "--prd", dest="tocheck", nargs="?", default=None) as prd. Initial software version can be specified with forcever.
"""
dp = tcllib.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("-p", "--prd", help="CU Reference # to filter scan results", dest="tocheck", nargs="?", default=None, metavar="PRD")
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
if args.forcever is not None: if args.forcever is not None:

View File

@ -19,10 +19,14 @@ fc.mode = fc.MODE.FULL
#fc.cltp = fc.CLTP.MOBILE #fc.cltp = fc.CLTP.MOBILE
fc.cltp = fc.CLTP.DESKTOP fc.cltp = fc.CLTP.DESKTOP
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.add_argument("tocheck", nargs="?", default=None) Finds new PRD numbers for all known variants, or specified variants with tocheck. Scan range
dp.add_argument("-f", "--floor", dest="floor", nargs="?", type=int, default=0) can be set by floor and ceiling switches.
dp.add_argument("-c", "--ceiling", dest="ceiling", nargs="?", type=int, default=999) """
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("tocheck", help="CU Reference # to filter scan results", nargs="?", default=None)
dp.add_argument("-f", "--floor", help="Beginning of scan range", dest="floor", nargs="?", type=int, default=0)
dp.add_argument("-c", "--ceiling", help="End of scan range", dest="ceiling", nargs="?", type=int, default=999)
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
floor = args.floor floor = args.floor

View File

@ -22,7 +22,11 @@ fc.mode = fc.MODE.FULL
#fc.cltp = fc.CLTP.MOBILE #fc.cltp = fc.CLTP.MOBILE
fc.cltp = fc.CLTP.DESKTOP fc.cltp = fc.CLTP.DESKTOP
dp = tcllib.DefaultParser(__file__) dpdesc = """
Finds new PRD numbers for a range of variants. Scan range can be set by
floor and ceiling switches.
"""
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("floor", nargs="?", help="Model number to start with", type=int, default=63116) dp.add_argument("floor", nargs="?", help="Model number to start with", type=int, default=63116)
dp.add_argument("ceiling", nargs="?", help="Model number to end with", type=int, default=99999) dp.add_argument("ceiling", nargs="?", help="Model number to end with", type=int, default=99999)
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])

View File

@ -13,10 +13,14 @@ fc = tcllib.FotaCheck()
fc.serid = "3531510" fc.serid = "3531510"
fc.mode = fc.MODE.OTA fc.mode = fc.MODE.OTA
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.add_argument("prd") Finds all valid OTA updates for a given PRD. Scan range can be set by
dp.add_argument("startver", nargs="?", default="AAA000") startver and endver switches.
dp.add_argument("endver", nargs="?", default="AAZ999") """
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("prd", help="CU Reference #, e.g. PRD-63117-011")
dp.add_argument("startver", help="Beginning of scan range", nargs="?", default="AAA000")
dp.add_argument("endver", help="End of scan range", nargs="?", default="AAZ999")
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
fc.curef = args.prd fc.curef = args.prd

View File

@ -12,18 +12,18 @@ fc = tcllib.FotaCheck()
fc.serid = "3531510" fc.serid = "3531510"
#fc.osvs = "7.1.1" #fc.osvs = "7.1.1"
dp = tcllib.DefaultParser(__file__) dpdesc = """
dp.description = """
Downloads the given firmware file. Downloads the given firmware file.
""" """
dp = tcllib.DefaultParser(__file__, dpdesc)
dp.add_argument("prd", nargs=1, help="CU Reference #, e.g. PRD-63117-011") dp.add_argument("prd", nargs=1, help="CU Reference #, e.g. PRD-63117-011")
dp.add_argument("targetversion", nargs=1, help="Firmware version to download, e.g. AAN990") dp.add_argument("targetversion", nargs=1, help="Firmware version to download, e.g. AAN990")
dp.add_argument("fwid", nargs=1, help="Numeric firmware file id, e.g. 268932") dp.add_argument("fwid", nargs=1, help="Numeric firmware file id, e.g. 268932")
dp.add_argument("-o", "--ota", metavar="FROMVERSION", help="download OTA from specified version (switches mode to OTA)", type=str) dp.add_argument("-o", "--ota", metavar="FROMVERSION", help="download OTA from specified version (switches mode to OTA)", type=str)
dp.add_argument("-i", "--imei", help="use specified IMEI instead of default", type=str) dp.add_argument("-i", "--imei", help="use specified IMEI instead of default", type=str)
dp.add_argument("-t", "--type", help="download device (default to desktop)", default="desktop", type=str, choices=["desktop", "mobile"]) dp.add_argument("-t", "--type", help="download device (default to desktop)", default="desktop", type=str, choices=["desktop", "mobile"])
dp.add_argument("--rawmode", help="override --mode with raw value (2=OTA, 4=FULL)") dp.add_argument("--rawmode", help="override --mode with raw value (2=OTA, 4=FULL)", metavar="MODE")
dp.add_argument("--rawcltp", help="override --type with raw value (10=MOBILE, 2010=DESKTOP)") dp.add_argument("--rawcltp", help="override --type with raw value (10=MOBILE, 2010=DESKTOP)", metavar="CLTP")
args = dp.parse_args(sys.argv[1:]) args = dp.parse_args(sys.argv[1:])
def sel_mode(defaultmode, rawval): def sel_mode(defaultmode, rawval):

View File

@ -14,6 +14,7 @@ import os
import platform import platform
import random import random
import time import time
import webbrowser
import xml.dom.minidom import xml.dom.minidom
import zlib import zlib
from collections import OrderedDict from collections import OrderedDict
@ -57,8 +58,17 @@ def default_enum(enumname, vardict):
class DefaultParser(argparse.ArgumentParser): class DefaultParser(argparse.ArgumentParser):
def __init__(self, appname): def __init__(self, appname, desc=None):
super().__init__(prog=appname.replace(".py", ""), epilog="https://github.com/mbirth/tcl_ota_check") super().__init__(prog=appname, description=desc, epilog="https://github.com/mbirth/tcl_ota_check")
self.add_argument("--webdb", help="open web database in browser and exit", action="store_true")
def parse_args(self, args=None, namespace=None):
if set(args) & {"--webdb"}: # if they intersect
webbrowser.open("https://tclota.birth-online.de/", new=2)
raise SystemExit
else:
argx = super().parse_args(args, namespace)
return argx
class FotaCheck: class FotaCheck: