dev-linux
parent
31e2d1a08c
commit
7ca1c2b6b3
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: pyOpenRPA
|
||||
Version: 1.1.2
|
||||
Version: 1.1.3
|
||||
Summary: First open source RPA platform for business
|
||||
Home-page: https://gitlab.com/UnicodeLabs/OpenRPA
|
||||
Author: Ivan Maslov
|
@ -1,2 +0,0 @@
|
||||
1. Настроить конфигурацию запуска/остановки robotDaemonConfiguration.json
|
||||
2. Запустить исполняемый файл демона runProcessOpenRPARobotDaemon_x32.cmd
|
@ -1,66 +0,0 @@
|
||||
# ATTENTION! HERE IS NO Relative import because it will be imported dynamically
|
||||
# All function check the flag SessionIsWindowResponsibleBool == True else no cammand is processed
|
||||
# All functions can return None, Bool or Dict { "IsSuccessful": True }
|
||||
from pyOpenRPA.Tools.RobotRDPActive import CMDStr # Create CMD Strings
|
||||
from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API
|
||||
def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.ProcessStartIfNotRunning: SessionIndex: {str(inSessionIndex)}, ProcessName: {inProcessName}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Create CMD str to stop process
|
||||
def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose):
|
||||
lResult = True
|
||||
lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||||
if inFlagForceClose:
|
||||
lCMDStr+= " /F"
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||
else:
|
||||
# TODO Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.ProcessStop: SessionIndex: {str(inSessionIndex)}, ProcessName: {inProcessName}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Send file from Host to Session RDP using shared drive in RDP
|
||||
def FileStoredSend(inGlobalDict, inSessionIndex, inHostFilePath, inRDPFilePath):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.FileStoredSend(inHostFilePath = inHostFilePath, inRDPFilePath = inRDPFilePath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.FileStoredSend: SessionIndex: {str(inSessionIndex)}, HostFilePath: {inHostFilePath}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Recieve file from Session RDP to Host using shared drive in RDP
|
||||
def FileStoredRecieve(inGlobalDict, inSessionIndex, inRDPFilePath, inHostFilePath):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.FileStoredRecieve(inRDPFilePath = inRDPFilePath, inHostFilePath = inHostFilePath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.FileStoredRecieve: SessionIndex: {str(inSessionIndex)}, HostFilePath: {inHostFilePath}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
@ -1,158 +0,0 @@
|
||||
from pyOpenRPA.Robot import UIDesktop
|
||||
from . import Connector
|
||||
import os
|
||||
import time # Time wait operations
|
||||
import importlib # from dynamic import module
|
||||
from . import ConnectorExceptions # Exceptions classes
|
||||
|
||||
|
||||
#Check for session is closed. Reopen if detected. Always keep session is active
|
||||
def Monitor(inGlobalDict, inListUpdateTimeout):
|
||||
lFlagWhile = True
|
||||
lResponsibilityCheckLastSec = time.time() # Get current time for check interval
|
||||
while lFlagWhile:
|
||||
try:
|
||||
# UIOSelector list init
|
||||
lUIOSelectorList = []
|
||||
#Prepare selectors list for check
|
||||
for lIndex, lItem in enumerate(inGlobalDict["RDPList"]):
|
||||
lUIOSelectorList.append([{"title_re": f"{lItem['SessionHex']}.*", "backend": "win32"}])
|
||||
#Run wait command
|
||||
#import pdb
|
||||
#pdb.set_trace()
|
||||
lRDPDissappearList = UIDesktop.UIOSelectorsSecs_WaitDisappear_List(lUIOSelectorList, inListUpdateTimeout)
|
||||
#print(lRDPDissappearList)
|
||||
###########################################
|
||||
#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["SessionIsWindowExistBool"]=False
|
||||
lItem["SessionIsWindowResponsibleBool"]=False
|
||||
#Kill all RDP sessions
|
||||
os.system('taskkill /F /im mstsc.exe')
|
||||
#Return from function
|
||||
return
|
||||
###########################################
|
||||
###########################################
|
||||
for lItem in lRDPDissappearList:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
#pdb.set_trace()
|
||||
#Session start if it is not in ignore list
|
||||
#add check for selector if it is not in ignoreIndexList
|
||||
if lItem not in inGlobalDict["OrchestratorToRobotStorage"]["IgnoreIndexList"]:
|
||||
try:
|
||||
Connector.Session(inGlobalDict["RDPList"][lItem])
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = True # Flag that session is started
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]= True
|
||||
# Write in logger - info
|
||||
inGlobalDict["Logger"].info(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session has been initialized!")
|
||||
# catch ConnectorExceptions.SessionWindowNotExistError
|
||||
except ConnectorExceptions.SessionWindowNotExistError as e:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session is not exist!")
|
||||
# catch ConnectorExceptions.SessionWindowNotResponsibleError
|
||||
except ConnectorExceptions.SessionWindowNotResponsibleError as e:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = True # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session is not responsible!")
|
||||
# general exceptions
|
||||
except Exception as e:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].exception(f"!!! ATTENTION !!! Unrecognized error")
|
||||
#######################
|
||||
# Click all warning messages
|
||||
Connector.SystemRDPWarningClickOk()
|
||||
#######################
|
||||
###########################################
|
||||
#Check if from Orchestrator full screen session is set
|
||||
if inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"] != inGlobalDict["FullScreenSessionIndex"]:
|
||||
#Do some switches
|
||||
#If full screen mode we have now
|
||||
if inGlobalDict["FullScreenSessionIndex"] is not None:
|
||||
if inGlobalDict["RDPList"][inGlobalDict["FullScreenSessionIndex"]]["SessionIsWindowExistBool"]:
|
||||
Connector.SessionScreen100x550(inGlobalDict["RDPList"][inGlobalDict["FullScreenSessionIndex"]]["SessionHex"])
|
||||
#If new session is setted
|
||||
if inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"] is not None:
|
||||
if inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionIsWindowExistBool"]:
|
||||
Connector.SessionScreenFull(inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionHex"])
|
||||
#Set one to other equal
|
||||
inGlobalDict["FullScreenSessionIndex"] = inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]
|
||||
###########################################
|
||||
####################################
|
||||
##### Block check responsibility interval [ResponsibilityCheckIntervalSec]
|
||||
if inGlobalDict['ResponsibilityCheckIntervalSec']: # Do check if ResponsibilityCheckIntervalSec is not None
|
||||
if (time.time - lResponsibilityCheckLastSec()) > inGlobalDict['ResponsibilityCheckIntervalSec']:
|
||||
# Set new time
|
||||
lResponsibilityCheckLastSec = time.time()
|
||||
# Do responsibility check
|
||||
for lIndex, lItem in enumerate(inGlobalDict["RDPList"]):
|
||||
# Check RDP responsibility
|
||||
lDoCheckResponsibilityBool = True
|
||||
lDoCheckResponsibilityCountMax = 20
|
||||
lDoCheckResponsibilityCountCurrent = 0
|
||||
while lDoCheckResponsibilityBool:
|
||||
# Enter full screen mode
|
||||
Connector.SessionScreenFull(lItem['SessionHex'])
|
||||
time.sleep(2)
|
||||
# Check responding
|
||||
lDoCheckResponsibilityBool = not Connector.SystemRDPIsResponsible()
|
||||
# Check if counter is exceed - raise exception
|
||||
if lDoCheckResponsibilityCountCurrent >= lDoCheckResponsibilityCountMax:
|
||||
lItem["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
lItem["SessionIsWindowResponsibleBool"]=False
|
||||
# Session window is not responsible - restart RDP (close window here - next loop will reconnect)
|
||||
Connector.SessionClose(lItem['SessionHex'])
|
||||
# Turn off the loop
|
||||
lDoCheckResponsibilityBool = False
|
||||
else:
|
||||
# Exit fullscreen mode
|
||||
Connector.SessionScreen100x550(lItem['SessionHex'])
|
||||
# Wait if is not responding
|
||||
if lDoCheckResponsibilityBool:
|
||||
time.sleep(3)
|
||||
# increase the couter
|
||||
lDoCheckResponsibilityCountCurrent+=1
|
||||
####################################
|
||||
# Check ActivityList from orchestrator
|
||||
lActivityListNew = []
|
||||
lActivityListOld = inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"]+inGlobalDict["ActivityListStart"]
|
||||
inGlobalDict["ActivityListStart"] = []
|
||||
for lActivityItem in lActivityListOld:
|
||||
#################
|
||||
#Call function from Activity structure
|
||||
################################################
|
||||
lSubmoduleFunctionName = lActivityItem["DefName"]
|
||||
lFileFullPath = lActivityItem["ModulePath"] # "path\\to\\module.py"
|
||||
lModuleName = (lFileFullPath.split("\\")[-1])[0:-3]
|
||||
lTechSpecification = importlib.util.spec_from_file_location(lModuleName, lFileFullPath)
|
||||
lTechModuleFromSpec = importlib.util.module_from_spec(lTechSpecification)
|
||||
lTechSpecificationModuleLoader = lTechSpecification.loader.exec_module(lTechModuleFromSpec)
|
||||
# Set gSettings in module
|
||||
lTechModuleFromSpec.gSettings = inGlobalDict
|
||||
if lSubmoduleFunctionName in dir(lTechModuleFromSpec):
|
||||
# Run SettingUpdate function in submodule
|
||||
#mGlobalDict = getattr(lTechModuleFromSpec, lSubmoduleFunctionName)()
|
||||
lActivityItemResult=getattr(lTechModuleFromSpec, lSubmoduleFunctionName)(*lActivityItem["ArgList"],**lActivityItem["ArgDict"])
|
||||
lActivityItemResultType = type(lActivityItemResult)
|
||||
# Check if Result is bool
|
||||
if lActivityItemResultType is bool:
|
||||
if not lActivityItemResult:
|
||||
# Activity is not done - add to list (retry in future)
|
||||
lActivityListNew.append(lActivityItem)
|
||||
#################################################
|
||||
inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"] = lActivityListNew # Override the value
|
||||
except RuntimeError as e:
|
||||
# case noGUI error passed - do nothing
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"Host session has lost the GUI")
|
||||
finally:
|
||||
# Wait for the next iteration
|
||||
time.sleep(0.7)
|
||||
return None
|
||||
#TODO Def garbage window cleaner (if connection was lost)
|
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: pyOpenRPA
|
||||
Version: 1.1.2
|
||||
Version: 1.1.3
|
||||
Summary: First open source RPA platform for business
|
||||
Home-page: https://gitlab.com/UnicodeLabs/OpenRPA
|
||||
Author: Ivan Maslov
|
@ -1,2 +0,0 @@
|
||||
1. Настроить конфигурацию запуска/остановки robotDaemonConfiguration.json
|
||||
2. Запустить исполняемый файл демона runProcessOpenRPARobotDaemon_x32.cmd
|
@ -1,66 +0,0 @@
|
||||
# ATTENTION! HERE IS NO Relative import because it will be imported dynamically
|
||||
# All function check the flag SessionIsWindowResponsibleBool == True else no cammand is processed
|
||||
# All functions can return None, Bool or Dict { "IsSuccessful": True }
|
||||
from pyOpenRPA.Tools.RobotRDPActive import CMDStr # Create CMD Strings
|
||||
from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API
|
||||
def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.ProcessStartIfNotRunning: SessionIndex: {str(inSessionIndex)}, ProcessName: {inProcessName}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Create CMD str to stop process
|
||||
def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose):
|
||||
lResult = True
|
||||
lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||||
if inFlagForceClose:
|
||||
lCMDStr+= " /F"
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||
else:
|
||||
# TODO Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.ProcessStop: SessionIndex: {str(inSessionIndex)}, ProcessName: {inProcessName}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Send file from Host to Session RDP using shared drive in RDP
|
||||
def FileStoredSend(inGlobalDict, inSessionIndex, inHostFilePath, inRDPFilePath):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.FileStoredSend(inHostFilePath = inHostFilePath, inRDPFilePath = inRDPFilePath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.FileStoredSend: SessionIndex: {str(inSessionIndex)}, HostFilePath: {inHostFilePath}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
||||
# Recieve file from Session RDP to Host using shared drive in RDP
|
||||
def FileStoredRecieve(inGlobalDict, inSessionIndex, inRDPFilePath, inHostFilePath):
|
||||
lResult = True
|
||||
lCMDStr = CMDStr.FileStoredRecieve(inRDPFilePath = inRDPFilePath, inHostFilePath = inHostFilePath)
|
||||
# Calculate the session Hex
|
||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||
# Check is Session is responsible
|
||||
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||
# Run CMD
|
||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||
else:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"GlobalDictSessionIndex_Defs.FileStoredRecieve: SessionIndex: {str(inSessionIndex)}, HostFilePath: {inHostFilePath}:: Session is not responsible!")
|
||||
lResult = False # Set false result - function has not been done
|
||||
return lResult
|
@ -1,158 +0,0 @@
|
||||
from pyOpenRPA.Robot import UIDesktop
|
||||
from . import Connector
|
||||
import os
|
||||
import time # Time wait operations
|
||||
import importlib # from dynamic import module
|
||||
from . import ConnectorExceptions # Exceptions classes
|
||||
|
||||
|
||||
#Check for session is closed. Reopen if detected. Always keep session is active
|
||||
def Monitor(inGlobalDict, inListUpdateTimeout):
|
||||
lFlagWhile = True
|
||||
lResponsibilityCheckLastSec = time.time() # Get current time for check interval
|
||||
while lFlagWhile:
|
||||
try:
|
||||
# UIOSelector list init
|
||||
lUIOSelectorList = []
|
||||
#Prepare selectors list for check
|
||||
for lIndex, lItem in enumerate(inGlobalDict["RDPList"]):
|
||||
lUIOSelectorList.append([{"title_re": f"{lItem['SessionHex']}.*", "backend": "win32"}])
|
||||
#Run wait command
|
||||
#import pdb
|
||||
#pdb.set_trace()
|
||||
lRDPDissappearList = UIDesktop.UIOSelectorsSecs_WaitDisappear_List(lUIOSelectorList, inListUpdateTimeout)
|
||||
#print(lRDPDissappearList)
|
||||
###########################################
|
||||
#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["SessionIsWindowExistBool"]=False
|
||||
lItem["SessionIsWindowResponsibleBool"]=False
|
||||
#Kill all RDP sessions
|
||||
os.system('taskkill /F /im mstsc.exe')
|
||||
#Return from function
|
||||
return
|
||||
###########################################
|
||||
###########################################
|
||||
for lItem in lRDPDissappearList:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
#pdb.set_trace()
|
||||
#Session start if it is not in ignore list
|
||||
#add check for selector if it is not in ignoreIndexList
|
||||
if lItem not in inGlobalDict["OrchestratorToRobotStorage"]["IgnoreIndexList"]:
|
||||
try:
|
||||
Connector.Session(inGlobalDict["RDPList"][lItem])
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = True # Flag that session is started
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]= True
|
||||
# Write in logger - info
|
||||
inGlobalDict["Logger"].info(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session has been initialized!")
|
||||
# catch ConnectorExceptions.SessionWindowNotExistError
|
||||
except ConnectorExceptions.SessionWindowNotExistError as e:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session is not exist!")
|
||||
# catch ConnectorExceptions.SessionWindowNotResponsibleError
|
||||
except ConnectorExceptions.SessionWindowNotResponsibleError as e:
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowExistBool"] = True # Set flag that session is disconnected
|
||||
inGlobalDict["RDPList"][lItem]["SessionIsWindowResponsibleBool"]=False
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"SessionHex: {str(inGlobalDict['RDPList'][lItem]['SessionHex'])}:: Session is not responsible!")
|
||||
# general exceptions
|
||||
except Exception as e:
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].exception(f"!!! ATTENTION !!! Unrecognized error")
|
||||
#######################
|
||||
# Click all warning messages
|
||||
Connector.SystemRDPWarningClickOk()
|
||||
#######################
|
||||
###########################################
|
||||
#Check if from Orchestrator full screen session is set
|
||||
if inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"] != inGlobalDict["FullScreenSessionIndex"]:
|
||||
#Do some switches
|
||||
#If full screen mode we have now
|
||||
if inGlobalDict["FullScreenSessionIndex"] is not None:
|
||||
if inGlobalDict["RDPList"][inGlobalDict["FullScreenSessionIndex"]]["SessionIsWindowExistBool"]:
|
||||
Connector.SessionScreen100x550(inGlobalDict["RDPList"][inGlobalDict["FullScreenSessionIndex"]]["SessionHex"])
|
||||
#If new session is setted
|
||||
if inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"] is not None:
|
||||
if inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionIsWindowExistBool"]:
|
||||
Connector.SessionScreenFull(inGlobalDict["RDPList"][inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]]["SessionHex"])
|
||||
#Set one to other equal
|
||||
inGlobalDict["FullScreenSessionIndex"] = inGlobalDict["OrchestratorToRobotStorage"]["FullScreenSessionIndex"]
|
||||
###########################################
|
||||
####################################
|
||||
##### Block check responsibility interval [ResponsibilityCheckIntervalSec]
|
||||
if inGlobalDict['ResponsibilityCheckIntervalSec']: # Do check if ResponsibilityCheckIntervalSec is not None
|
||||
if (time.time - lResponsibilityCheckLastSec()) > inGlobalDict['ResponsibilityCheckIntervalSec']:
|
||||
# Set new time
|
||||
lResponsibilityCheckLastSec = time.time()
|
||||
# Do responsibility check
|
||||
for lIndex, lItem in enumerate(inGlobalDict["RDPList"]):
|
||||
# Check RDP responsibility
|
||||
lDoCheckResponsibilityBool = True
|
||||
lDoCheckResponsibilityCountMax = 20
|
||||
lDoCheckResponsibilityCountCurrent = 0
|
||||
while lDoCheckResponsibilityBool:
|
||||
# Enter full screen mode
|
||||
Connector.SessionScreenFull(lItem['SessionHex'])
|
||||
time.sleep(2)
|
||||
# Check responding
|
||||
lDoCheckResponsibilityBool = not Connector.SystemRDPIsResponsible()
|
||||
# Check if counter is exceed - raise exception
|
||||
if lDoCheckResponsibilityCountCurrent >= lDoCheckResponsibilityCountMax:
|
||||
lItem["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||
lItem["SessionIsWindowResponsibleBool"]=False
|
||||
# Session window is not responsible - restart RDP (close window here - next loop will reconnect)
|
||||
Connector.SessionClose(lItem['SessionHex'])
|
||||
# Turn off the loop
|
||||
lDoCheckResponsibilityBool = False
|
||||
else:
|
||||
# Exit fullscreen mode
|
||||
Connector.SessionScreen100x550(lItem['SessionHex'])
|
||||
# Wait if is not responding
|
||||
if lDoCheckResponsibilityBool:
|
||||
time.sleep(3)
|
||||
# increase the couter
|
||||
lDoCheckResponsibilityCountCurrent+=1
|
||||
####################################
|
||||
# Check ActivityList from orchestrator
|
||||
lActivityListNew = []
|
||||
lActivityListOld = inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"]+inGlobalDict["ActivityListStart"]
|
||||
inGlobalDict["ActivityListStart"] = []
|
||||
for lActivityItem in lActivityListOld:
|
||||
#################
|
||||
#Call function from Activity structure
|
||||
################################################
|
||||
lSubmoduleFunctionName = lActivityItem["DefName"]
|
||||
lFileFullPath = lActivityItem["ModulePath"] # "path\\to\\module.py"
|
||||
lModuleName = (lFileFullPath.split("\\")[-1])[0:-3]
|
||||
lTechSpecification = importlib.util.spec_from_file_location(lModuleName, lFileFullPath)
|
||||
lTechModuleFromSpec = importlib.util.module_from_spec(lTechSpecification)
|
||||
lTechSpecificationModuleLoader = lTechSpecification.loader.exec_module(lTechModuleFromSpec)
|
||||
# Set gSettings in module
|
||||
lTechModuleFromSpec.gSettings = inGlobalDict
|
||||
if lSubmoduleFunctionName in dir(lTechModuleFromSpec):
|
||||
# Run SettingUpdate function in submodule
|
||||
#mGlobalDict = getattr(lTechModuleFromSpec, lSubmoduleFunctionName)()
|
||||
lActivityItemResult=getattr(lTechModuleFromSpec, lSubmoduleFunctionName)(*lActivityItem["ArgList"],**lActivityItem["ArgDict"])
|
||||
lActivityItemResultType = type(lActivityItemResult)
|
||||
# Check if Result is bool
|
||||
if lActivityItemResultType is bool:
|
||||
if not lActivityItemResult:
|
||||
# Activity is not done - add to list (retry in future)
|
||||
lActivityListNew.append(lActivityItem)
|
||||
#################################################
|
||||
inGlobalDict["OrchestratorToRobotResetStorage"]["ActivityList"] = lActivityListNew # Override the value
|
||||
except RuntimeError as e:
|
||||
# case noGUI error passed - do nothing
|
||||
# Write in logger - warning
|
||||
inGlobalDict["Logger"].warning(f"Host session has lost the GUI")
|
||||
finally:
|
||||
# Wait for the next iteration
|
||||
time.sleep(0.7)
|
||||
return None
|
||||
#TODO Def garbage window cleaner (if connection was lost)
|
Loading…
Reference in new issue