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

checksum tweak

This commit is contained in:
thurask 2018-02-06 20:04:21 -05:00
parent 0b7ae53861
commit 28ed2365ab
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048

View File

@ -15,15 +15,19 @@ from . import credentials
class TclChecksumMixin: class TclChecksumMixin:
"""A mixin component for TCL's checksum API.""" """A mixin component for TCL's checksum API."""
def do_checksum(self, encslave, address, uri): @staticmethod
"""Perform checksum request with given parameters.""" def prep_checksum(encslave, address, uri):
"""Prepare URL and parameters for checksum request."""
url = "http://" + encslave + "/checksum.php" url = "http://" + encslave + "/checksum.php"
params = credentials.get_creds2() params = credentials.get_creds2()
payload = {address: uri} payload = {address: uri}
payload_json = json.dumps(payload) payload_json = json.dumps(payload)
params[b"address"] = bytes(payload_json, "utf-8") params[b"address"] = bytes(payload_json, "utf-8")
return url, params
def do_checksum(self, encslave, address, uri):
"""Perform checksum request with given parameters."""
url, params = self.prep_checksum(encslave, address, uri)
# print(repr(dict(params))) # print(repr(dict(params)))
req = self.sess.post(url, data=params) req = self.sess.post(url, data=params)
if req.status_code == 200: if req.status_code == 200: