2017-08-15 14:20:26 +01:00
|
|
|
#!/usr/bin/env python3
|
2017-08-18 23:49:12 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-10-05 23:25:45 +01:00
|
|
|
# pylint: disable=C0111,C0326,C0103
|
2017-08-15 14:20:26 +01:00
|
|
|
|
2017-09-01 12:59:12 +01:00
|
|
|
import random
|
2017-08-08 05:24:16 +01:00
|
|
|
import sys
|
2017-10-05 23:25:45 +01:00
|
|
|
import tcllib
|
2017-08-05 15:25:42 +01:00
|
|
|
|
2017-09-01 12:43:10 +01:00
|
|
|
fc = tcllib.FotaCheck()
|
2017-09-23 22:31:32 +01:00
|
|
|
fc.cltp = 10
|
|
|
|
fc.serid = "3531510"
|
|
|
|
#fc.osvs = "7.1.1"
|
|
|
|
|
2017-09-01 12:43:10 +01:00
|
|
|
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.mode = fc.MODE_OTA
|
|
|
|
elif len(sys.argv) == 2: # python tclcheck.py $PRD = FULL for $PRD
|
|
|
|
fc.curef = sys.argv[1]
|
2017-09-23 22:31:32 +01:00
|
|
|
fc.fv = "AAA000"
|
2017-09-01 12:43:10 +01:00
|
|
|
fc.mode = fc.MODE_FULL
|
2017-09-23 22:31:32 +01:00
|
|
|
fc.cltp = 2010
|
2017-09-01 12:43:10 +01:00
|
|
|
else: # python tclcheck.py = OTA for default PRD, FV
|
|
|
|
fc.curef = "PRD-63117-011"
|
|
|
|
fc.fv = "AAM481"
|
|
|
|
fc.mode = fc.MODE_OTA
|
|
|
|
|
|
|
|
check_xml = fc.do_check()
|
2017-09-01 12:59:12 +01:00
|
|
|
print(fc.pretty_xml(check_xml))
|
2017-09-01 12:43:10 +01:00
|
|
|
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
|
|
|
|
|
|
|
req_xml = fc.do_request(curef, fv, tv, fw_id)
|
|
|
|
print(fc.pretty_xml(req_xml))
|
|
|
|
fileid, fileurl, slaves, encslaves = fc.parse_request(req_xml)
|
|
|
|
|
|
|
|
for s in slaves:
|
|
|
|
print("http://{}{}".format(s, fileurl))
|
|
|
|
|
|
|
|
if fc.mode == fc.MODE_FULL:
|
2017-09-01 13:07:06 +01:00
|
|
|
header = fc.do_encrypt_header(random.choice(encslaves), fileurl)
|
|
|
|
if len(header) == 4194320:
|
2017-09-07 17:54:17 +01:00
|
|
|
print("Header length check passed. Writing to header_{}.bin.".format(tv))
|
|
|
|
with open("header_{}.bin".format(tv), "wb") as f:
|
2017-09-01 13:07:06 +01:00
|
|
|
f.write(header)
|
|
|
|
else:
|
|
|
|
print("Header length invalid ({}).".format(len(header)))
|