parent
bc56245394
commit
dcbdb0e7da
@ -0,0 +1,10 @@
|
|||||||
|
#####################################
|
||||||
|
# RobotRDPActive Exceptions class
|
||||||
|
#####################################
|
||||||
|
class SessionWindowNotExistError(Exception): pass #Error when Window not exists
|
||||||
|
class SessionWindowNotResponsibleError(Exception): pass # Error when Window not responding
|
||||||
|
class HostNoGUIError(Exception): pass # Orchestrator session has no GUI
|
||||||
|
#try:
|
||||||
|
# raise SessionWindowNotResponsibleError("Test")
|
||||||
|
#except SessionWindowNotResponsibleError as e:
|
||||||
|
# print("Catched")
|
@ -1,18 +1,66 @@
|
|||||||
# ATTENTION! HERE IS NO Relative import because it will be imported dynamically
|
# 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 CMDStr # Create CMD Strings
|
||||||
from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API
|
from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API
|
||||||
def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||||||
|
lResult = True
|
||||||
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath)
|
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath)
|
||||||
# Calculate the session Hex
|
# Calculate the session Hex
|
||||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||||
# Run CMD
|
# Run CMD
|
||||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
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
|
# Create CMD str to stop process
|
||||||
def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose):
|
def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose):
|
||||||
|
lResult = True
|
||||||
lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||||||
if inFlagForceClose:
|
if inFlagForceClose:
|
||||||
lCMDStr+= " /F"
|
lCMDStr+= " /F"
|
||||||
# Calculate the session Hex
|
# Calculate the session Hex
|
||||||
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
lSessionHex = inGlobalDict["RDPList"][inSessionIndex]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RDPList"][inSessionIndex]["SessionIsWindowResponsibleBool"]:
|
||||||
# Run CMD
|
# Run CMD
|
||||||
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
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
|
Loading…
Reference in new issue