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

use argparse

This commit is contained in:
thurask 2017-10-10 15:25:38 -04:00
parent 0d250087f9
commit 173060dff1
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048
5 changed files with 38 additions and 24 deletions

View File

@ -12,12 +12,17 @@ fc.cltp = 10
fc.serid = "3531510"
#fc.osvs = "7.1.1"
dp = tcllib.DefaultParser(__file__)
dp.add_argument("prd", nargs="?", default="AAM481")
dp.add_argument("fvver", nargs="?", default="PRD-63117-011")
args = dp.parse_args(sys.argv[1:])
if len(sys.argv) == 3: # python tclcheck.py $PRD $FV = OTA delta for $PRD from $FV
fc.curef = sys.argv[1]
fc.fv = sys.argv[2]
fc.curef = args.prd
fc.fv = args.fvver
fc.mode = fc.MODE_OTA
elif len(sys.argv) == 2: # python tclcheck.py $PRD = FULL for $PRD
fc.curef = sys.argv[1]
fc.curef = args.prd
fc.fv = "AAA000"
fc.mode = fc.MODE_FULL
fc.cltp = 2010

View File

@ -15,11 +15,14 @@ fc.serid = "3531510"
fc.mode = fc.MODE_OTA
fc.cltp = 10
force_ver = False
force_ver_text = ""
if len(sys.argv) > 1:
force_ver = sys.argv[1]
force_ver_text = " from {}".format(force_ver)
dp = tcllib.DefaultParser(__file__)
dp.add_argument("forcever", nargs="?", default=None)
args = dp.parse_args(sys.argv[1:])
if args.forcever is not None:
force_ver_text = " from {}".format(args.forcever)
else:
force_ver_text = ""
print("List of latest OTA firmware{} by PRD:".format(force_ver_text))
@ -27,8 +30,8 @@ with open("prds.txt", "r") as f:
for prdline in f:
prdline = prdline.strip()
prd, lastver, model = prdline.split(" ", 2)
if force_ver != False:
lastver = force_ver
if args.forcever is not None:
lastver = args.forcever
try:
fc.reset_session()
fc.curef = prd

View File

@ -19,6 +19,10 @@ fc.mode = fc.MODE_FULL
#fc.cltp = 10
fc.cltp = 2010
dp = tcllib.DefaultParser(__file__)
dp.add_argument("tocheck", nargs="?", default=None)
args = dp.parse_args(sys.argv[1:])
print("Valid PRDs not already in database:")
with open("prds.txt", "r") as afile:
@ -30,13 +34,12 @@ with open("prds.txt", "r") as afile:
for key, value in prdc.items():
prddict[key].append(value)
if len(sys.argv) > 1:
if args.tocheck is not None:
prdkeys = list(prddict.keys())
for k in prdkeys:
if k != sys.argv[1]:
if k != args.tocheck:
del prddict[k]
for center in sorted(prddict.keys()):
tails = [int(i) for i in prddict[center]]
total_count = 1000 - len(tails)

View File

@ -13,18 +13,15 @@ fc = tcllib.FotaCheck()
fc.serid = "3531510"
fc.mode = fc.MODE_OTA
if len(sys.argv) < 2:
print("Syntax: {} PRD [STARTVER] [ENDVER]".format(sys.argv[0]))
sys.exit()
dp = tcllib.DefaultParser(__file__)
dp.add_argument("prd")
dp.add_argument("startver", nargs="?", default="AAA000")
dp.add_argument("endver", nargs="?", default="AAZ999")
args = dp.parse_args(sys.argv[1:])
start_ver = "AAA000"
end_ver = "AAZ999"
if len(sys.argv) >= 2:
fc.curef = sys.argv[1]
if len(sys.argv) >= 3:
start_ver = sys.argv[2]
if len(sys.argv) >= 4:
end_ver = sys.argv[3]
fc.curef = args.prd
start_ver = args.startver
end_ver = args.endver
print("Valid firmwares for model {} (between {} and {}):".format(fc.curef, start_ver, end_ver))

View File

@ -2,6 +2,7 @@
# pylint: disable=C0111,C0326
import argparse
import base64
import binascii
import hashlib
@ -35,6 +36,11 @@ def make_escapes_work():
colorama.init()
class DefaultParser(argparse.ArgumentParser):
def __init__(self, appname):
super().__init__(prog=appname.replace(".py", ""), epilog="https://github.com/mbirth/tcl_ota_check")
class FotaCheck:
VDKEY = b"eJwdjwEOwDAIAr8kKFr//7HhmqXp8AIIDrYAgg8byiUXrwRJRXja+d6iNxu0AhUooDCN9rd6rDLxmGIakUVWo3IGCTRWqCAt6X4jGEIUAxgN0eYWnp+LkpHQAg/PsO90ELsy0Npm/n2HbtPndFgGEV31R9OmT4O4nrddjc3Qt6nWscx7e+WRHq5UnOudtjw5skuV09pFhvmqnOEIs4ljPeel1wfLYUF4\n"
CKTP_CHECKAUTO = 1