in rabbitmq/management/commands/resync_cached_commissions.py [0:0]
def next_page_of_commissions(self, url:str, shared_secret:str, start_at:int, length:int):
"""
generator that yields a commission dictionary
:param url:
:param shared_secret:
:param start_at:
:param length:
:return:
"""
urlpath = "/api/pluto/commission?startAt={}&length={}".format(start_at, length)
signed_headers = Command.sign_request({}, "GET", urlpath, "application/octet-stream", "", shared_secret)
response = requests.get(url + urlpath, headers=signed_headers, verify=False)
if response.status_code==200:
content = response.json()
for entry in content["result"]:
yield entry
elif response.status_code==404:
raise Exception("Endpoint not found? This indicates a code bug")
elif response.status_code==503 or response.status_code==502:
logger.warning("pluto-core not responding. Trying again in a few seconds...")
time.sleep(3)
for entry in self.next_page_of_commissions(url, shared_secret, start_at, length):
yield entry
else:
logger.error("Server error {0}".format(response.status_code))
logger.error(response.text)
raise Exception("Server error")