From 16bdd675b81b5b905d6a9848f28dd6fc37f33cbd Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sat, 5 Dec 2020 22:01:05 +0300 Subject: [PATCH] Some fixes after test --- Agent/AgentDaemonX64.cmd | 2 +- Agent/AgentSettings.py | 2 +- Sources/pyOpenRPA/Agent/A2O.py | 21 +++++++++---------- Sources/pyOpenRPA/Agent/O2A.py | 10 ++++++--- .../pyOpenRPA/Orchestrator/ServerSettings.py | 1 + 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Agent/AgentDaemonX64.cmd b/Agent/AgentDaemonX64.cmd index b84d5675..e4b4a029 100644 --- a/Agent/AgentDaemonX64.cmd +++ b/Agent/AgentDaemonX64.cmd @@ -1,4 +1,4 @@ cd %~dp0 -copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe +copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\pythonw.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe .\..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe "AgentSettings.py" pause >nul \ No newline at end of file diff --git a/Agent/AgentSettings.py b/Agent/AgentSettings.py index d21b8106..73aefed5 100644 --- a/Agent/AgentSettings.py +++ b/Agent/AgentSettings.py @@ -14,7 +14,7 @@ if __name__ == "__main__": # New init way "IsHTTPSBool": False, # True - if server is secured HTTPS, False - if server is not secured HTTP "HostStr":"127.0.0.1", "PortInt":80, - "SuperTokenStr":"", # Access token to Orchestrator + "SuperTokenStr":"1992-04-03-0643-ru-b4ff-openrpa52zzz", # Access token to Orchestrator }, "O2ADict":{ "IsOnlineBool": True, # Parameter can be changed when program executes diff --git a/Sources/pyOpenRPA/Agent/A2O.py b/Sources/pyOpenRPA/Agent/A2O.py index 99f6a336..c01209ae 100644 --- a/Sources/pyOpenRPA/Agent/A2O.py +++ b/Sources/pyOpenRPA/Agent/A2O.py @@ -10,17 +10,16 @@ import requests, time # Send logs to orchestrator def _A2ODataSend(inGSettings, inDataDict): lL = inGSettings["Logger"] - while inGSettings["A2O"]["IsOnlineBool"]: - # Send request to the orchestrator server - try: - lProtocolStr= "https" if inGSettings["OrchestratorDict"]["IsHTTPSBool"] else "http" - lHostStr = inGSettings["OrchestratorDict"]["HostStr"] - lPortInt = inGSettings["OrchestratorDict"]["PortInt"] - lURLStr=f"{lProtocolStr}://{lHostStr}:{lPortInt}/pyOpenRPA/Agent/A2O" - lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, data=inDataDict) - except Exception as e: - if lL: lL.exception(f"A2O Error handler. Sleep for {inGSettings['A2O']['RetryTimeoutSecFloat']} s.") - time.sleep(inGSettings["A2O"]["RetryTimeoutSecFloat"]) + # Send request to the orchestrator server + try: + lProtocolStr= "https" if inGSettings["OrchestratorDict"]["IsHTTPSBool"] else "http" + lHostStr = inGSettings["OrchestratorDict"]["HostStr"] + lPortInt = inGSettings["OrchestratorDict"]["PortInt"] + lURLStr=f"{lProtocolStr}://{lHostStr}:{lPortInt}/pyOpenRPA/Agent/A2O" + lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, json=inDataDict) + except Exception as e: + if lL: lL.exception(f"A2O Error handler.") + # Send some logs to orchestrator def LogListSend(inGSettings, inLogList): diff --git a/Sources/pyOpenRPA/Agent/O2A.py b/Sources/pyOpenRPA/Agent/O2A.py index 937b05bb..fdc772ae 100644 --- a/Sources/pyOpenRPA/Agent/O2A.py +++ b/Sources/pyOpenRPA/Agent/O2A.py @@ -9,7 +9,7 @@ import requests, time def O2A_Loop(inGSettings): lL = inGSettings["Logger"] - while inGSettings["O2A"]["IsOnlineBool"]: + while inGSettings["O2ADict"]["IsOnlineBool"]: # Send request to the orchestrator server try: lProtocolStr= "https" if inGSettings["OrchestratorDict"]["IsHTTPSBool"] else "http" @@ -17,6 +17,10 @@ def O2A_Loop(inGSettings): lPortInt = inGSettings["OrchestratorDict"]["PortInt"] lURLStr=f"{lProtocolStr}://{lHostStr}:{lPortInt}/pyOpenRPA/Agent/O2A" lDataDict = { "HostNameUpperStr": inGSettings["AgentDict"]["HostNameUpperStr"], "UserUpperStr": inGSettings["AgentDict"]["UserUpperStr"]} - lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, data=lDataDict) + lResponse = requests.post(url= lURLStr, cookies = {"AuthToken":inGSettings["OrchestratorDict"]["SuperTokenStr"]}, json=lDataDict) + if lResponse.status_code != 200: + if lL: lL.warning(f"Agent can not connect to Orchestrator. Below the response from the orchestrator:{lResponse}") + time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"]) except Exception as e: - time.sleep(inGSettings["O2A"]["RetryTimeoutSecFloat"]) \ No newline at end of file + if lL: lL.exception(f"A2O Error handler. Sleep for {inGSettings['A2ODict']['RetryTimeoutSecFloat']} s.") + time.sleep(inGSettings["O2ADict"]["RetryTimeoutSecFloat"]) \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py index 0db93705..d57c0cd9 100644 --- a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py @@ -202,6 +202,7 @@ def pyOpenRPA_Agent_A2O(inRequest, inGSettings): if inRequest.headers.get('Content-Length') is not None: lInputByteArrayLength = int(inRequest.headers.get('Content-Length')) lInputByteArray = inRequest.rfile.read(lInputByteArrayLength) + print(lInputByteArray) # Превращение массива байт в объект lInput = json.loads(lInputByteArray.decode('utf8')) if "LogList" in lInput: