Доп. управление
+ Add. controls
{{#FooterButtonX1List}}
{{{Text}}}
diff --git a/Sources/pyOpenRPA/Robot/OrchestratorConnector.py b/Sources/pyOpenRPA/Robot/OrchestratorConnector.py
index 04970093..d7e00ab2 100644
--- a/Sources/pyOpenRPA/Robot/OrchestratorConnector.py
+++ b/Sources/pyOpenRPA/Robot/OrchestratorConnector.py
@@ -7,6 +7,11 @@ import copy
from .Utils import TimerRepeat # Timer which can repeating
mLogger=logging.getLogger("OrchestratorConnector")
#########################
+mTimerList=[]
+def IntervalTerminateAll():
+ for lItem in mTimerList:
+ lItem.stop()
+#########################
# Создать файл логирования
# add filemode="w" to overwrite
if not os.path.exists("Reports"):
@@ -22,6 +27,9 @@ mLoggerFH.setFormatter(mLoggerFormatter)
# add handler to logger object
mLogger.addHandler(mLoggerFH)
############################################
+#Turn loggin level ERROR
+def LoggerSetLevelError():
+ mLogger.setLevel(logging.ERROR)
#from requests import async
import json
###################################
@@ -120,6 +128,8 @@ def IntervalDataReceiveAsync(*args, **kwargs):
del lKwargs["Interval"]
lTimer = TimerRepeat.TimerRepeat(lInterval, DataReceiveAsync, lArgs, lKwargs)
lTimer.start()
+ #Add timer to general list to stop this when needed
+ mTimerList.append(lTimer)
return lTimer
################################################################################
###################################
@@ -216,6 +226,8 @@ def IntervalDataSendAsync(*args,**kwargs):
del lKwargs["Interval"]
lTimer = TimerRepeat.TimerRepeat(lInterval, DataSendAsync, lArgs, lKwargs)
lTimer.start()
+ #Add timer to general list to stop this when needed
+ mTimerList.append(lTimer)
return lTimer
################################################################################
###################################
@@ -297,6 +309,8 @@ def IntervalDataSendResetAsync(*args,**kwargs):
del lKwargs["Interval"]
lTimer = TimerRepeat.TimerRepeat(lInterval, DataSendResetAsync, lArgs, lKwargs)
lTimer.start()
+ #Add timer to general list to stop this when needed
+ mTimerList.append(lTimer)
return lTimer
################################################################################
# Check changes in orchestrator - then replace in RobotStorage if not equeal. Has no timeout because You can use function IntervalDataReceiveResetAsync (asynchronyous)
@@ -371,6 +385,8 @@ def IntervalDataReceiveResetAsync(*args,**kwargs):
del lKwargs["Interval"]
lTimer = TimerRepeat.TimerRepeat(lInterval, DataReceiveResetAsync, lArgs, lKwargs)
lTimer.start()
+ #Add timer to general list to stop this when needed
+ mTimerList.append(lTimer)
return lTimer
#################################################################################
#################################################################################
diff --git a/Sources/pyOpenRPA/Studio/Studio.py b/Sources/pyOpenRPA/Studio/Studio.py
index d6857031..f9f89074 100644
--- a/Sources/pyOpenRPA/Studio/Studio.py
+++ b/Sources/pyOpenRPA/Studio/Studio.py
@@ -148,6 +148,6 @@ def run():
# Logging
mGlobalDict["Logger"].info(f"Server init. Listen URL: {inServerAddress}, Listen port: {inPort}")
# Запуск адреса в браузере
- os.system("explorer http://127.0.0.1:8081")
+ os.system(f"explorer http://127.0.0.1:{str(inPort)}")
httpd.serve_forever()
run()
diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py
index 511aa45b..096f6ca9 100644
--- a/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py
+++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/Connector.py
@@ -84,7 +84,7 @@ def SessionRDPStart(inRDPFilePath):
[{"title_re": f"{lRDPFileName} — .*",
"class_name": "TscShellContainerClass", "backend": "win32"}]
],
- 60
+ 30
)
#Click if 0 is appear (RUS)
if 0 in lWaitResult:
@@ -99,7 +99,7 @@ def SessionRDPStart(inRDPFilePath):
[{"title_re": f"{lRDPFileName} — .*",
"class_name": "TscShellContainerClass", "backend": "win32"}]
],
- 60
+ 30
)
# Click if 1 is appear (ENG)
if 1 in lWaitResult:
@@ -115,7 +115,7 @@ def SessionRDPStart(inRDPFilePath):
[{"title_re": f"{lRDPFileName} — .*",
"class_name": "TscShellContainerClass", "backend": "win32"}]
],
- 60
+ 30
)
#Prepare little window
SessionScreen100x550(lRDPFileName)
diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py
index 3d7f5b93..242836c2 100644
--- a/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py
+++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/Monitor.py
@@ -1,17 +1,34 @@
from pyOpenRPA.Robot import UIDesktop
from . import Connector
+import os
import pdb
#Check for session is closed. Reopen if detected. Always keep session is active
def Monitor(inGlobalDict, inListUpdateTimeout):
- while True:
+ lFlagWhile = True
+ while lFlagWhile:
# UIOSelector list init
lUIOSelectorList = []
for lItem in inGlobalDict["RDPList"]:
lUIOSelectorList.append([{"title_re": f"{lItem['SessionHex']} — .*", "backend": "win32"}])
#Run wait command
lRDPDissappearList = UIDesktop.UIOSelectorsSecs_WaitDisappear_List(lUIOSelectorList, inListUpdateTimeout)
+ #Analyze if flag safeturn off is activated
+ if inGlobalDict.get("OrchestratorToRobotResetStorage",{}).get("SafeTurnOff",False):
+ lFlagWhile=False
+ #Set status disconnected for all RDP List
+ for lItem in inGlobalDict["RDPList"]:
+ lItem["FlagSessionIsActive"]=False
+ #Kill all RDP sessions
+ os.system('taskkill /F /im mstsc.exe')
+ #Return from function
+ return
for lItem in lRDPDissappearList:
+ inGlobalDict["RDPList"][lItem]["FlagSessionIsActive"] = False # Set flag that session is disconnected
#pdb.set_trace()
#Session start
- Connector.Session(inGlobalDict["RDPList"][lItem])
- return None
\ No newline at end of file
+ try:
+ Connector.Session(inGlobalDict["RDPList"][lItem])
+ except Exception:
+ pass
+ return None
+#TODO Def garbage window cleaner (if connection was lost)
\ No newline at end of file
diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/SettingsExample.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/SettingsExample.py
deleted file mode 100644
index 02deb771..00000000
--- a/Sources/pyOpenRPA/Tools/RobotRDPActive/SettingsExample.py
+++ /dev/null
@@ -1,22 +0,0 @@
-#Robot RDPActive settings
-def Settings():
- mDict = {
- "RDPList":
- [
- {
- "Host": "77.77.22.22", # Host address
- "Port": "7777", # RDP Port
- "Login": "test", # Login
- "Password": "test", # Password
- "Screen": {
- "Width": 1680, #Width of the remote desktop in pixels
- "Height": 1050, #Height of the remote desktop in pixels
- # "640x480" or "1680x1050" or "FullScreen". If Resolution not exists set full screen
- "FlagUseAllMonitors": False, # True or False
- "DepthBit": "32" # "32" or "24" or "16" or "15"
- },
- "SessionHex":"" # Hex is created when robot runs
- }
- ]
- }
- return mDict
\ No newline at end of file
diff --git a/Sources/pyOpenRPA/Tools/RobotRDPActive/__main__.py b/Sources/pyOpenRPA/Tools/RobotRDPActive/__main__.py
index a3d0fe99..7217dbed 100644
--- a/Sources/pyOpenRPA/Tools/RobotRDPActive/__main__.py
+++ b/Sources/pyOpenRPA/Tools/RobotRDPActive/__main__.py
@@ -35,9 +35,15 @@ lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server C
os.system(lCMDString)
#time.sleep()
for lConfigurationItem in mGlobalDict["RDPList"]:
+ try:
Connector.Session(lConfigurationItem)
+ lConfigurationItem["FlagSessionIsActive"]=True #Flag that session is started
+ except Exception:
+ pass
#Run monitor
Monitor.Monitor(mGlobalDict, 1)
#Enable certificate warning
lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 2 /f'
-os.system(lCMDString)
\ No newline at end of file
+os.system(lCMDString)
+#Close all thread from OrchestratorConnection
+mGlobalDict["OrchestratorConnectorTerminateAll"]()
\ No newline at end of file
diff --git a/Utils/RobotRDPActive/SettingsExample.py b/Utils/RobotRDPActive/SettingsExample.py
index 02deb771..49771bae 100644
--- a/Utils/RobotRDPActive/SettingsExample.py
+++ b/Utils/RobotRDPActive/SettingsExample.py
@@ -1,4 +1,13 @@
#Robot RDPActive settings
+from pyOpenRPA.Robot import OrchestratorConnector
+import os
+import logging
+import datetime
+#Definitions
+lOrchestratorHost="localhost"
+lOrchestratorPort=8081
+lOrchestratorProtocol="http"
+lOrchestratorAuthToken="1992-04-03-0643-ru-b4ff-openrpa52zzz"
def Settings():
mDict = {
"RDPList":
@@ -15,8 +24,83 @@ def Settings():
"FlagUseAllMonitors": False, # True or False
"DepthBit": "32" # "32" or "24" or "16" or "15"
},
- "SessionHex":"" # Hex is created when robot runs
+ "SessionHex":"", # Hex is created when robot runs
+ "FlagSessionIsActive": False
+ }
+ ],
+ "Logger": logging.getLogger("RobotRDPActive"),
+ "OrchestratorToRobotStorage": {
+
+ },
+ "OrchestratorToRobotResetStorage": {
+ "SafeTurnOff":False #Control from orchestrator to safety turn off robot
+ },
+ "OrchestratorConnector": {
+ #Fill below
+ },
+ "OrchestratorConnectorTerminateAll":OrchestratorConnector.IntervalTermimateAll
+ }
+ ######################
+ #OrchestratorConnector
+ ######################
+ mDict["OrchestratorConnector"]={
+ "IntervalDataSendAsync": [
+ {
+ "Interval": 2.7,
+ "RobotStorage": mDict,
+ "RobotStorageKey": "RDPList",
+ "OrchestratorKeyList": ["Storage", "RobotRDPActive","RobotToOrchestratorStorage","RDPList"],
+ "OrchestratorProtocol": lOrchestratorProtocol,
+ "OrchestratorHost": lOrchestratorHost,
+ "OrchestratorPort": lOrchestratorPort,
+ "OrchestratorAuthToken": lOrchestratorAuthToken
+ }
+ ],
+ "IntervalDataReceiveResetAsync": [
+ {
+ "Interval": 3.3,
+ "RobotStorage": mDict,
+ "RobotStorageKey": "OrchestratorToRobotResetStorage",
+ "RobotResetValue": {"SafeTurnOff":False},
+ "OrchestratorKeyList": ["Storage", "RobotRDPActive","OrchestratorToRobotResetStorage"],
+ "OrchestratorProtocol": lOrchestratorProtocol,
+ "OrchestratorHost": lOrchestratorHost,
+ "OrchestratorPort": lOrchestratorPort,
+ "OrchestratorAuthToken": lOrchestratorAuthToken
+ }
+ ],
+ "IntervalDataReceiveAsync": [
+ {
+ "Interval": 3.6,
+ "RobotStorage": mDict,
+ "RobotStorageKey": "OrchestratorToRobotStorage",
+ "OrchestratorKeyList": ["Storage", "RobotRDPActive","OrchestratorToRobotStorage"],
+ "OrchestratorProtocol": lOrchestratorProtocol,
+ "OrchestratorHost": lOrchestratorHost,
+ "OrchestratorPort": lOrchestratorPort,
+ "OrchestratorAuthToken": lOrchestratorAuthToken
}
]
}
+ #Turn off many warnings from orchestrator connector logger
+ OrchestratorConnector.LoggerSetLevelError()
+ #Run OrchestratorConnector initialization
+ OrchestratorConnector.ConfigurationInit(mDict["OrchestratorConnector"])
+ #########################
+ #Создать файл логирования
+ # add filemode="w" to overwrite
+ if not os.path.exists("Reports"):
+ os.makedirs("Reports")
+ ##########################
+ #Подготовка логгера Robot
+ #########################
+ mRobotLogger=mDict["Logger"]
+ mRobotLogger.setLevel(logging.INFO)
+ # create the logging file handler
+ mRobotLoggerFH = logging.FileHandler("Reports\ReportRobotRDPActive_"+datetime.datetime.now().strftime("%Y_%m_%d")+".log")
+ mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+ mRobotLoggerFH.setFormatter(mRobotLoggerFormatter)
+ # add handler to logger object
+ mRobotLogger.addHandler(mRobotLoggerFH)
+ ############################################
return mDict
\ No newline at end of file
diff --git a/Utils/RobotRDPActive/pyOpenRPA.Tools.RobotRDPActive_x64.cmd b/Utils/RobotRDPActive/pyOpenRPA.Tools.RobotRDPActive_x64.cmd
index dc05d29d..78a1b58f 100644
--- a/Utils/RobotRDPActive/pyOpenRPA.Tools.RobotRDPActive_x64.cmd
+++ b/Utils/RobotRDPActive/pyOpenRPA.Tools.RobotRDPActive_x64.cmd
@@ -1,3 +1,4 @@
cd %~dp0..\..\Sources
-..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe -m pyOpenRPA.Tools.RobotRDPActive "C:\Abs\Archive\scopeSrcUL\OpenRPA_Creds\RobotRDPActive\SettingsVSK.py"
+copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_RobotRDPActive.exe
+..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_RobotRDPActive.exe -m pyOpenRPA.Tools.RobotRDPActive "C:\Abs\Archive\scopeSrcUL\OpenRPA_Creds\RobotRDPActive\SettingsVSK.py"
pause >nul
\ No newline at end of file