From c4f835b3cfada62b3ecb588e30b9b0f59e856b81 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Wed, 1 Apr 2020 15:56:16 +0300 Subject: [PATCH] # Minor fixes in RobotRDPActive # RobotRDPActive SpeedUp --- Orchestrator/Settings/ControlPanel_RobotRDPActive.py | 12 +++++++++++- Sources/pyOpenRPA/Robot/OrchestratorConnector.py | 7 +++++++ Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py | 4 +++- Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py | 5 +++-- Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py | 7 +++++-- .../RobotRDPActive/SettingsRobotRDPActiveExample.py | 8 ++++---- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Orchestrator/Settings/ControlPanel_RobotRDPActive.py b/Orchestrator/Settings/ControlPanel_RobotRDPActive.py index 1e76458b..dd018264 100644 --- a/Orchestrator/Settings/ControlPanel_RobotRDPActive.py +++ b/Orchestrator/Settings/ControlPanel_RobotRDPActive.py @@ -17,6 +17,16 @@ def RenderRobotRDPActive(inGlobalConfiguration): lOnClickSafeTurnOff = "mGlobal.Processor.ServerValueSet(['Storage','RobotRDPActive','OrchestratorToRobotResetStorage','SafeTurnOff'],true);" #Force close button lOnClickForceCloseButton=f"mGlobal.Controller.CMDRunText('taskkill /F /im {lProcessName}');" + # # # # # Add recieve file activity + lTestRecieveActivityList = [ + { + "ModulePath": f"{os.path.join(lRobotRDPActiveFolderPath,'Defs_SessionIndex.py')}", # "Session\\SessionDefs.py" + "DefName":"FileStoredRecieve", # Function name + "ArgList":[], # Args list + "ArgDict":{"inSessionIndex": 0, "inHostFilePath": "testRecieve.txt","inRDPFilePath": "C:\\Temp\\testRecieve.txt"} # Args dictionary + } + ] + lOnClickTestSendBaumanStr = f"mGlobal.Processor.ServerValueSet(['Storage','RobotRDPActive','OrchestratorToRobotResetStorage','ActivityList'],{json.dumps(lTestRecieveActivityList)});" #Result template lResultDict={ "HeaderLeftText":"Keep active RDP sessions", @@ -63,7 +73,7 @@ def RenderRobotRDPActive(inGlobalConfiguration): ################################ #Session state lItemSessionState='Disconnected' - if lItem.get("SessionIsWindowExistBool",False): + if lItem.get("SessionIsWindowResponsibleBool",False): lItemSessionState='Connected' lResultDict["BodyKeyValueList"].append({"Key":f"[{str(lRDPListIndex)}]{lLabelSessionFullScreen}{lLabelIsIgnored}{lItem.get('Host','localhost')}:{lItem.get('Port','--')}","Value":f"{lItem.get('Login','--')}, {lItem.get('SessionHex','--')}, State {lItemSessionState}, {lSetFullScreenA}, {lIgnoreIndexListLink}"}) lRDPListIndex = lRDPListIndex + 1 diff --git a/Sources/pyOpenRPA/Robot/OrchestratorConnector.py b/Sources/pyOpenRPA/Robot/OrchestratorConnector.py index d7e00ab2..d79e2489 100644 --- a/Sources/pyOpenRPA/Robot/OrchestratorConnector.py +++ b/Sources/pyOpenRPA/Robot/OrchestratorConnector.py @@ -383,6 +383,13 @@ def IntervalDataReceiveResetAsync(*args,**kwargs): if "Interval" in lKwargs: lInterval = lKwargs["Interval"] del lKwargs["Interval"] + # Reset the storage before start + DataSendSync( + RobotValue=lKwargs["RobotResetValue"], + OrchestratorKeyList=lKwargs["OrchestratorKeyList"], OrchestratorProtocol=lKwargs["OrchestratorProtocol"], + OrchestratorHost=lKwargs["OrchestratorHost"], OrchestratorPort=lKwargs["OrchestratorPort"], + OrchestratorAuthToken=lKwargs["OrchestratorAuthToken"] + ) lTimer = TimerRepeat.TimerRepeat(lInterval, DataReceiveResetAsync, lArgs, lKwargs) lTimer.start() #Add timer to general list to stop this when needed diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py index 992e28e1..cb03065f 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/CMDStr.py @@ -17,8 +17,10 @@ def FileStoredSend(inHostFilePath, inRDPFilePath): lHostFileAbsPath = os.path.join("\\\\tsclient", os.path.abspath(inHostFilePath).replace(":","")) # \\tsclient\C\path\to\file lHostRDPFileAbsPath = os.path.abspath(inRDPFilePath) # File location in RDP lResult = f'copy /Y "{lHostFileAbsPath}" "{lHostRDPFileAbsPath}"' + return lResult # Send file from Session RDP to Host using shared drive in RDP (force copy) def FileStoredRecieve(inRDPFilePath, inHostFilePath): lHostFileAbsPath = os.path.join("\\\\tsclient", os.path.abspath(inHostFilePath).replace(":","")) # \\tsclient\C\path\to\file lHostRDPFileAbsPath = os.path.abspath(inRDPFilePath) # File location in RDP - lResult = f'copy /Y "{lHostRDPFileAbsPath}" "{lHostFileAbsPath}"' \ No newline at end of file + lResult = f'copy /Y "{lHostRDPFileAbsPath}" "{lHostFileAbsPath}"' + return lResult \ No newline at end of file diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py index facc60c0..f2f7c757 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py @@ -142,6 +142,7 @@ def SessionRDPStart(inRDPFilePath): time.sleep(3) # set the fullscreen SessionScreenFull(inSessionHex=lRDPFileName) + time.sleep(1) # Check RDP responsibility lDoCheckResponsibilityBool = True lDoCheckResponsibilityCountMax = 20 @@ -198,14 +199,14 @@ def SessionClose(inSessionHexStr): # "IsResponsibleBool": True|False # Flag is RDP is responsible - works only when inModeStr = CROSSCHECK # } # example Connector.SessionCMDRun("4d1e48f3ff6c45cc810ea25d8adbeb50","start notepad", "RUN") -def SessionCMDRun(inSessionHex,inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK"): +def SessionCMDRun(inSessionHex,inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboardTimeoutSec = 5): # Init the result dict lResult = {"OutStr": None,"IsResponsibleBool":True} # Enter full screen mode SessionScreenFull(inSessionHex) time.sleep(2) # Run CMD operations - lResult = SystemCMDRun(inCMDCommandStr = inCMDCommandStr, inModeStr = inModeStr) + lResult = SystemCMDRun(inCMDCommandStr = inCMDCommandStr, inModeStr = inModeStr, inClipboardTimeoutSec = inClipboardTimeoutSec) # Exit fullscreen mode SessionScreen100x550(inSessionHex) # Check if session is in Full screen mode diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py index d35a52d2..ed7b9fc5 100644 --- a/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py +++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py @@ -5,6 +5,7 @@ import time # Time wait operations import pdb import importlib # from dynamic import module from . import ConnectorExceptions # Exceptions classes +import copy #Check for session is closed. Reopen if detected. Always keep session is active def Monitor(inGlobalDict, inListUpdateTimeout): lFlagWhile = True @@ -120,7 +121,9 @@ def Monitor(inGlobalDict, inListUpdateTimeout): #################################### # Check ActivityList from orchestrator lActivityListNew = [] - for lActivityItem in inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"]: + lActivityListOld = inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"]+inGlobalDict["ActivityListStart"] + inGlobalDict["ActivityListStart"] = [] + for lActivityItem in lActivityListOld: ################# #Call function from Activity structure ################################################ @@ -150,6 +153,6 @@ def Monitor(inGlobalDict, inListUpdateTimeout): inGlobalDict["Logger"].warning(f"Host session has lost the GUI") finally: # Wait for the next iteration - time.sleep(2) + time.sleep(0.7) return None #TODO Def garbage window cleaner (if connection was lost) \ No newline at end of file diff --git a/Utils/RobotRDPActive/SettingsRobotRDPActiveExample.py b/Utils/RobotRDPActive/SettingsRobotRDPActiveExample.py index 42a62bdf..bfe412d2 100644 --- a/Utils/RobotRDPActive/SettingsRobotRDPActiveExample.py +++ b/Utils/RobotRDPActive/SettingsRobotRDPActiveExample.py @@ -99,7 +99,7 @@ def Settings(): mDict["OrchestratorConnector"]={ "IntervalDataSendAsync": [ { - "Interval": 2.7, + "Interval": 1.1, "RobotStorage": mDict, "RobotStorageKey": "RDPList", "OrchestratorKeyList": ["Storage", "RobotRDPActive","RobotToOrchestratorStorage","RDPList"], @@ -109,7 +109,7 @@ def Settings(): "OrchestratorAuthToken": lOrchestratorAuthToken }, { - "Interval": 2.7, + "Interval": 1, "RobotStorage": mDict, "RobotStorageKey": "RDPList", "OrchestratorKeyList": ["Storage", "RobotRDPActive","RobotToOrchestratorStorage","FullScreenSessionIndex"], @@ -121,7 +121,7 @@ def Settings(): ], "IntervalDataReceiveResetAsync": [ { - "Interval": 3.3, + "Interval": 1.05, "RobotStorage": mDict, "RobotStorageKey": "OrchestratorToRobotResetStorage", "RobotResetValue": mDict["OrchestratorToRobotResetStorage"], @@ -134,7 +134,7 @@ def Settings(): ], "IntervalDataReceiveAsync": [ { - "Interval": 1.5, + "Interval": 1.25, "RobotStorage": mDict, "RobotStorageKey": "OrchestratorToRobotStorage", "OrchestratorKeyList": ["Storage", "RobotRDPActive","OrchestratorToRobotStorage"],