def get_time_permits(self, hash_mpin_id_hex, signature):
# Get time permit from the local D-TA
url = url_concat(
"{0}/{1}".format(options.DTALocalURL.rstrip("/"), "timePermits"), {
'hash_mpin_id': hash_mpin_id_hex,
'signature': signature,
'count': random.randint(PERMITS_MIN, PERMITS_MAX) if options.cacheTimePermits else 1})
response = yield self.http_client.fetch(url)
if response.error:
log.error("DTA timePermit failed, URL: {0}. Code: {1}, Reason: {2}".format(url, response.code, response.reason))
raise HTTPError(500)
if response.body:
try:
response_data = json.loads(response.body)
raise tornado.gen.Return(response_data["timePermits"])
except (ValueError, KeyError):
log.error("DTA /timePermit Failed. Invalid JSON response".format(
response.body))
raise HTTPError(500)
评论列表
文章目录