2018-02-02 02:05:31 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# pylint: disable=C0111,C0326,C0103
|
|
|
|
|
2018-02-03 21:25:26 +00:00
|
|
|
"""Return checksum for given firmware."""
|
|
|
|
|
2018-02-02 02:05:31 +00:00
|
|
|
import sys
|
2018-02-03 20:24:36 +00:00
|
|
|
|
2018-02-11 00:12:41 +00:00
|
|
|
from tcllib import argparser
|
2018-02-11 01:38:38 +00:00
|
|
|
from tcllib.requests import ChecksumRequest, RequestRunner, ServerSelector
|
2018-02-02 02:05:31 +00:00
|
|
|
|
|
|
|
encslaves = [
|
|
|
|
"54.238.56.196",
|
|
|
|
"46.51.183.28",
|
|
|
|
"75.101.149.79",
|
|
|
|
"54.249.227.45",
|
|
|
|
"54.249.227.54",
|
|
|
|
"54.225.78.202",
|
|
|
|
"54.225.87.236",
|
|
|
|
"54.195.239.239",
|
|
|
|
"54.195.240.212",
|
|
|
|
]
|
|
|
|
|
|
|
|
dpdesc = """
|
|
|
|
Returns the checksum for a given firmware URI.
|
|
|
|
"""
|
2018-02-11 00:12:41 +00:00
|
|
|
dp = argparser.DefaultParser(__file__, dpdesc)
|
2018-02-02 02:05:31 +00:00
|
|
|
dp.add_argument("uri", help="URI to firmware, starts with '/body/...'")
|
|
|
|
args = dp.parse_args(sys.argv[1:])
|
|
|
|
|
|
|
|
fileurl = args.uri
|
|
|
|
|
|
|
|
# /body/ce570ddc079e2744558f191895e524d02a60476f/32/268932
|
|
|
|
#fileurl = "/body/ce570ddc079e2744558f191895e524d02a60476f/2c23717bb747f3c321195419f451de52efa8ea51/263790/268932"
|
|
|
|
|
2018-02-11 00:12:41 +00:00
|
|
|
runner = RequestRunner(ServerSelector(encslaves), https=False)
|
|
|
|
|
|
|
|
cks = ChecksumRequest(fileurl, fileurl)
|
|
|
|
runner.run(cks)
|
|
|
|
|
|
|
|
if not cks.success:
|
|
|
|
print("{}".format(cks.error))
|
|
|
|
sys.exit(4)
|
|
|
|
cksres = cks.get_result()
|
|
|
|
print(cksres.pretty_xml())
|