import logging from core.apirequest import executeRequest from core.execution import processregistry def responsePolicy(response, action, outputs, resolved): if hasattr(action, "responsepolicy"): #if processregistry.registeredOp: #currentOp = processregistry.registeredOp #print(registeredOp[action.name]["response"]) #print(currentOp) if not response.ok: logging.warning(f"{response} during {action.name}") for policy in action.responsepolicy: if policy["statuscode"] == response.status_code: logging.warning(policy["print"]) from core.execution.executioncontract import executeContract executeContract(policy["execute"]) #newresponse = executeRequest(action, outputs, resolved) if policy["response_update"]: logging.info("Updating response") newresponse = executeRequest(action, outputs, resolved) #response = newresponse if processregistry.registeredOp: response = processregistry.registeredOp[action.name]["response"] else: response = newresponse break return response