| Total Complexity | 0 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python3 |
||
| 2 | # -*- coding: utf-8 -*- |
||
| 3 | |||
| 4 | # pylint: disable=C0111,C0326,C0103 |
||
| 5 | |||
| 6 | """Return checksum for given firmware.""" |
||
| 7 | |||
| 8 | import sys |
||
| 9 | |||
| 10 | from tcllib import argparser |
||
| 11 | from tcllib.requests import ChecksumRequest, RequestRunner, ServerSelector |
||
| 12 | |||
| 13 | encslaves = [ |
||
| 14 | "54.238.56.196", |
||
| 15 | "46.51.183.28", |
||
| 16 | "75.101.149.79", |
||
| 17 | "54.249.227.45", |
||
| 18 | "54.249.227.54", |
||
| 19 | "54.225.78.202", |
||
| 20 | "54.225.87.236", |
||
| 21 | "54.195.239.239", |
||
| 22 | "54.195.240.212", |
||
| 23 | ] |
||
| 24 | |||
| 25 | dpdesc = """ |
||
| 26 | Returns the checksum for a given firmware URI. |
||
| 27 | """ |
||
| 28 | dp = argparser.DefaultParser(__file__, dpdesc) |
||
| 29 | dp.add_argument("uri", help="URI to firmware, starts with '/body/...'") |
||
| 30 | args = dp.parse_args(sys.argv[1:]) |
||
| 31 | |||
| 32 | fileurl = args.uri |
||
| 33 | |||
| 34 | # /body/ce570ddc079e2744558f191895e524d02a60476f/32/268932 |
||
| 35 | #fileurl = "/body/ce570ddc079e2744558f191895e524d02a60476f/2c23717bb747f3c321195419f451de52efa8ea51/263790/268932" |
||
| 36 | |||
| 37 | runner = RequestRunner(ServerSelector(encslaves), https=False) |
||
| 38 | |||
| 39 | cks = ChecksumRequest(fileurl, fileurl) |
||
| 40 | runner.run(cks) |
||
| 41 | |||
| 42 | if not cks.success: |
||
| 43 | print("{}".format(cks.error)) |
||
| 44 | sys.exit(4) |
||
| 45 | cksres = cks.get_result() |
||
| 46 | print(cksres.pretty_xml()) |
||
| 47 |