|
|
@ -26,25 +26,31 @@ def O2A_Loop(inGSettings):
|
|
|
|
lPortInt = inGSettings["OrchestratorDict"]["PortInt"]
|
|
|
|
lPortInt = inGSettings["OrchestratorDict"]["PortInt"]
|
|
|
|
lURLStr=f"{lProtocolStr}://{lHostStr}:{lPortInt}/pyOpenRPA/Agent/O2A"
|
|
|
|
lURLStr=f"{lProtocolStr}://{lHostStr}:{lPortInt}/pyOpenRPA/Agent/O2A"
|
|
|
|
lDataDict = { "HostNameUpperStr": inGSettings["AgentDict"]["HostNameUpperStr"], "UserUpperStr": inGSettings["AgentDict"]["UserUpperStr"], "ActivityLastGUIDStr": lActivityLastGUIDStr}
|
|
|
|
lDataDict = { "HostNameUpperStr": inGSettings["AgentDict"]["HostNameUpperStr"], "UserUpperStr": inGSettings["AgentDict"]["UserUpperStr"], "ActivityLastGUIDStr": lActivityLastGUIDStr}
|
|
|
|
lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, json=lDataDict)
|
|
|
|
lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, json=lDataDict, timeout=inGSettings["O2ADict"]["ConnectionTimeoutSecFloat"])
|
|
|
|
if lResponse.status_code != 200:
|
|
|
|
if lResponse.status_code != 200:
|
|
|
|
if lL: lL.warning(f"Agent can not connect to Orchestrator. Below the response from the orchestrator:{lResponse}")
|
|
|
|
if lL: lL.warning(f"Agent can not connect to Orchestrator. Below the response from the orchestrator:{lResponse}")
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
lRequestBody = lResponse.text
|
|
|
|
lRequestBody = lResponse.text
|
|
|
|
|
|
|
|
if len(lRequestBody) != 0: # CHeck if not empty result when close the connection from orch
|
|
|
|
lQueueItem = lResponse.json() # Try to get JSON
|
|
|
|
lQueueItem = lResponse.json() # Try to get JSON
|
|
|
|
# Append QUEUE item in ProcessorDict > ActivityList
|
|
|
|
# Append QUEUE item in ProcessorDict > ActivityList
|
|
|
|
lActivityLastGUIDStr = lQueueItem["GUIDStr"]
|
|
|
|
lActivityLastGUIDStr = lQueueItem["GUIDStr"]
|
|
|
|
inGSettings["ProcessorDict"]["ActivityList"].append(lQueueItem)
|
|
|
|
inGSettings["ProcessorDict"]["ActivityList"].append(lQueueItem)
|
|
|
|
if lL: lL.debug(f"ActivityItem was received from orchestrator: {lQueueItem}");
|
|
|
|
if lL: lL.debug(f"ActivityItem was received from orchestrator: {lQueueItem}");
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if lL: lL.debug(f"Empty response from the orchestrator - loop when refresh the connection between Orc and Agent");
|
|
|
|
except requests.exceptions.ConnectionError as e:
|
|
|
|
except requests.exceptions.ConnectionError as e:
|
|
|
|
if lL: lL.error(f"O2A Connection error - orchestrator is not available. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
if lL: lL.error(f"O2A Connection error - orchestrator is not available. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
except ConnectionResetError as e:
|
|
|
|
except ConnectionResetError as e:
|
|
|
|
if lL: lL.error(f"O2A Connection error - orchestrator is not available. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
if lL: lL.error(f"O2A Connection reset error - orchestrator is not available. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
except json.decoder.JSONDecodeError as e:
|
|
|
|
except json.decoder.JSONDecodeError as e:
|
|
|
|
if lL: lL.error(f"See body of the recieved content from the Orchestrator: {lRequestBody}")
|
|
|
|
if lL: lL.error(f"O2A JSON decode error - See body of the recieved content from the Orchestrator: {lRequestBody}")
|
|
|
|
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
|
|
|
|
except requests.exceptions.Timeout as e:
|
|
|
|
|
|
|
|
if lL: lL.exception(f"O2A requests timeout error (no response for long time). Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"])
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
if lL: lL.exception(f"O2A Error handler. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|
if lL: lL.exception(f"O2A Error handler. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.")
|
|
|
|