parent
d809a9d5c7
commit
b8e4cd82b5
@ -0,0 +1,152 @@
|
|||||||
|
# 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 . import CMDStr # Create CMD Strings
|
||||||
|
from . import Connector # RDP API
|
||||||
|
from . import ConnectorExceptions # Exceptions
|
||||||
|
import time # sleep function
|
||||||
|
# ATTENTION
|
||||||
|
gSettings = None # Gsettings will be initialized after the import module
|
||||||
|
|
||||||
|
# Create new RDPSession in RobotRDPActive
|
||||||
|
def RDPSessionConnect(inRDPSessionKeyStr, inHostStr, inPortStr, inLoginStr, inPasswordStr):
|
||||||
|
lRDPConfigurationItem = { # Init the configuration item
|
||||||
|
"Host": inHostStr, # Host address, example "77.77.22.22"
|
||||||
|
"Port": inPortStr, # RDP Port, example "3389"
|
||||||
|
"Login": inLoginStr, # Login, example "test"
|
||||||
|
"Password": inPasswordStr, # Password, example "test"
|
||||||
|
"Screen": {
|
||||||
|
"Width": 1680, # Width of the remote desktop in pixels, example 1680
|
||||||
|
"Height": 1050, # Height of the remote desktop in pixels, example 1050
|
||||||
|
# "640x480" or "1680x1050" or "FullScreen". If Resolution not exists set full screen, example
|
||||||
|
"FlagUseAllMonitors": False, # True or False, example False
|
||||||
|
"DepthBit": "32" # "32" or "24" or "16" or "15", example "32"
|
||||||
|
},
|
||||||
|
"SharedDriveList": ["c"], # List of the Root sesion hard drives, example ["c"]
|
||||||
|
###### Will updated in program ############
|
||||||
|
"SessionHex": "77777sdfsdf77777dsfdfsf77777777", # Hex is created when robot runs, example ""
|
||||||
|
"SessionIsWindowExistBool": False, # Flag if the RDP window is exist, old name "FlagSessionIsActive". Check every n seconds , example False
|
||||||
|
"SessionIsWindowResponsibleBool": False, # Flag if RDP window is responsible (recieve commands). Check every nn seconds. If window is Responsible - window is Exist too , example False
|
||||||
|
"SessionIsIgnoredBool": False # Flag to ignore RDP window False - dont ignore, True - ignore, example False
|
||||||
|
}
|
||||||
|
# Add item in RDPList
|
||||||
|
gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr] = lRDPConfigurationItem
|
||||||
|
# Create the RDP session
|
||||||
|
Connector.Session(lRDPConfigurationItem)
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Disconnect the RDP session
|
||||||
|
def RDPSessionDisconnect(inRDPSessionKeyStr):
|
||||||
|
global gSettings
|
||||||
|
lSessionHex = gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]["SessionHex"]
|
||||||
|
gSettings["RobotRDPActive"]["RDPList"].pop(inRDPSessionKeyStr,None)
|
||||||
|
Connector.SessionClose(inSessionHexStr=lSessionHex)
|
||||||
|
return True
|
||||||
|
|
||||||
|
# RDP Session reconnect
|
||||||
|
def RDPSessionReconnect(inRDPSessionKeyStr):
|
||||||
|
global gSettings
|
||||||
|
lRDPConfigurationItem = gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]
|
||||||
|
RDPSessionDisconnect(inRDPSessionKeyStr=inRDPSessionKeyStr) # Disconnect the RDP
|
||||||
|
# Add item in RDPList
|
||||||
|
gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr] = lRDPConfigurationItem
|
||||||
|
# Create the RDP session
|
||||||
|
Connector.Session(lRDPConfigurationItem)
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Check RDP Session responsibility TODO NEED DEV + TEST
|
||||||
|
def RDPSessionResponsibilityCheck(inRDPSessionKeyStr):
|
||||||
|
global gSettings
|
||||||
|
inGlobalDict = gSettings
|
||||||
|
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]["SessionHex"]
|
||||||
|
# set the fullscreen
|
||||||
|
Connector.SessionScreenFull(inSessionHex=lSessionHex)
|
||||||
|
time.sleep(1)
|
||||||
|
# Check RDP responsibility
|
||||||
|
lDoCheckResponsibilityBool = True
|
||||||
|
lDoCheckResponsibilityCountMax = 20
|
||||||
|
lDoCheckResponsibilityCountCurrent = 0
|
||||||
|
while lDoCheckResponsibilityBool:
|
||||||
|
# Check if counter is exceed - raise exception
|
||||||
|
if lDoCheckResponsibilityCountCurrent >= lDoCheckResponsibilityCountMax:
|
||||||
|
pass
|
||||||
|
#raise ConnectorExceptions.SessionWindowNotResponsibleError("Error when initialize the RDP session - RDP window is not responding!")
|
||||||
|
# Check responding
|
||||||
|
lDoCheckResponsibilityBool = not Connector.SystemRDPIsResponsible()
|
||||||
|
# Wait if is not responding
|
||||||
|
if lDoCheckResponsibilityBool:
|
||||||
|
time.sleep(3)
|
||||||
|
# increase the couter
|
||||||
|
lDoCheckResponsibilityCountCurrent+=1
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Start process if it is not running
|
||||||
|
def RDPSessionProcessStartIfNotRunning(inRDPSessionKey, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||||||
|
global gSettings
|
||||||
|
inGlobalDict = gSettings
|
||||||
|
lResult = True
|
||||||
|
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath, inFlagGetAbsPath= inFlagGetAbsPath)
|
||||||
|
# Calculate the session Hex
|
||||||
|
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionIsWindowResponsibleBool"]:
|
||||||
|
# Run CMD
|
||||||
|
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||||
|
else:
|
||||||
|
# Write in logger - warning
|
||||||
|
inGlobalDict["Logger"].warning(f"Defs_SessionIndex.ProcessStartIfNotRunning: SessionIndex: {str(inRDPSessionKey)}, 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 RDPSessionProcessStop(inRDPSessionKey, inProcessName, inFlagForceClose):
|
||||||
|
global gSettings
|
||||||
|
inGlobalDict = gSettings
|
||||||
|
lResult = True
|
||||||
|
lCMDStr = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||||||
|
if inFlagForceClose:
|
||||||
|
lCMDStr+= " /F"
|
||||||
|
# Calculate the session Hex
|
||||||
|
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionIsWindowResponsibleBool"]:
|
||||||
|
# Run CMD
|
||||||
|
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
|
||||||
|
else:
|
||||||
|
# TODO Write in logger - warning
|
||||||
|
inGlobalDict["Logger"].warning(f"Defs_SessionIndex.ProcessStop: SessionIndex: {str(inRDPSessionKey)}, 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 RDPSessionFileStoredSend(inRDPSessionKey, inHostFilePath, inRDPFilePath):
|
||||||
|
global gSettings
|
||||||
|
inGlobalDict = gSettings
|
||||||
|
lResult = True
|
||||||
|
lCMDStr = CMDStr.FileStoredSend(inHostFilePath = inHostFilePath, inRDPFilePath = inRDPFilePath)
|
||||||
|
# Calculate the session Hex
|
||||||
|
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionIsWindowResponsibleBool"]:
|
||||||
|
# Run CMD
|
||||||
|
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||||
|
else:
|
||||||
|
# Write in logger - warning
|
||||||
|
inGlobalDict["Logger"].warning(f"Defs_SessionIndex.FileStoredSend: SessionIndex: {str(inRDPSessionKey)}, 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 RDPSessionFileStoredRecieve(inRDPSessionKey, inRDPFilePath, inHostFilePath):
|
||||||
|
global gSettings
|
||||||
|
inGlobalDict = gSettings
|
||||||
|
lResult = True
|
||||||
|
lCMDStr = CMDStr.FileStoredRecieve(inRDPFilePath = inRDPFilePath, inHostFilePath = inHostFilePath)
|
||||||
|
# Calculate the session Hex
|
||||||
|
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionHex"]
|
||||||
|
# Check is Session is responsible
|
||||||
|
if inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKey]["SessionIsWindowResponsibleBool"]:
|
||||||
|
# Run CMD
|
||||||
|
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120)
|
||||||
|
else:
|
||||||
|
# Write in logger - warning
|
||||||
|
inGlobalDict["Logger"].warning(f"Defs_SessionIndex.FileStoredRecieve: SessionIndex: {str(inRDPSessionKey)}, HostFilePath: {inHostFilePath}:: Session is not responsible!")
|
||||||
|
lResult = False # Set false result - function has not been done
|
||||||
|
return lResult
|
@ -0,0 +1,142 @@
|
|||||||
|
from pyOpenRPA.Robot import UIDesktop
|
||||||
|
import os
|
||||||
|
import time # Time wait operations
|
||||||
|
from . import ConnectorExceptions # Exceptions classes
|
||||||
|
from . import Connector
|
||||||
|
from . import Processor # Module for process some functions on thr RDP
|
||||||
|
# Main function
|
||||||
|
def RobotRDPActive(inGSettings):
|
||||||
|
# inGSettings = {
|
||||||
|
# ... "RobotRDPActive": {} ...
|
||||||
|
# }
|
||||||
|
#import pdb
|
||||||
|
#pdb.set_trace()
|
||||||
|
lLogger = inGSettings["Logger"] # Synonim
|
||||||
|
Processor.gSettings = inGSettings # Set gSettings in processor module
|
||||||
|
mGSettingsRDPActiveDict = inGSettings["RobotRDPActive"] # Get configuration from global dict settings
|
||||||
|
# Global error handler
|
||||||
|
try:
|
||||||
|
######## Init the RDP List
|
||||||
|
for lRDPSessionKeyStrItem in mGSettingsRDPActiveDict["RDPList"]:
|
||||||
|
lConfigurationItem = mGSettingsRDPActiveDict["RDPList"][lRDPSessionKeyStrItem]
|
||||||
|
lConfigurationItem["SessionIsWindowExistBool"] = False # Flag that session is not started
|
||||||
|
lConfigurationItem["SessionIsWindowResponsibleBool"] = False # Flag that session is not started
|
||||||
|
lConfigurationItem["SessionHex"] = " 77777sdfsdf77777dsfdfsf77777777" # Flag that session is not started
|
||||||
|
##########
|
||||||
|
# Run monitor - main loop
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
inGlobalDict = mGSettingsRDPActiveDict # Compatibility
|
||||||
|
inListUpdateTimeout = 1 # Compatibility
|
||||||
|
lFlagWhile = True
|
||||||
|
lResponsibilityCheckLastSec = time.time() # Get current time for check interval
|
||||||
|
while lFlagWhile:
|
||||||
|
try:
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# Check RDP window is OK - reconnect if connection was lost
|
||||||
|
lUIOSelectorList = []
|
||||||
|
lRDPConfigurationDictList = []
|
||||||
|
# Prepare selectors list for check
|
||||||
|
for lRDPSessionKeyStrItem in inGlobalDict["RDPList"]:
|
||||||
|
lItem = inGlobalDict["RDPList"][lRDPSessionKeyStrItem]
|
||||||
|
lRDPConfigurationDictList.append(lItem) # Add RDP Configuration in list
|
||||||
|
lUIOSelectorList.append([{"title_re": f"{lItem['SessionHex']}.*", "backend": "win32"}])
|
||||||
|
# Run wait command
|
||||||
|
lRDPDissappearList = UIDesktop.UIOSelectorsSecs_WaitDisappear_List(lUIOSelectorList, inListUpdateTimeout)
|
||||||
|
for lItem in lRDPDissappearList: # Reconnect if connection was lost
|
||||||
|
lRDPConfigurationDict = lRDPConfigurationDictList[lItem] # Get RDP Configuration list
|
||||||
|
lRDPConfigurationDict["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||||
|
# Check if RDP window is not ignored
|
||||||
|
if not lRDPConfigurationDict["SessionIsIgnoredBool"]:
|
||||||
|
try:
|
||||||
|
Connector.Session(lRDPConfigurationDict)
|
||||||
|
lRDPConfigurationDict["SessionIsWindowExistBool"] = True # Flag that session is started
|
||||||
|
# Write in logger - info
|
||||||
|
lLogger.info(
|
||||||
|
f"SessionHex: {str(lRDPConfigurationDict['SessionHex'])}:: Session has been initialized!")
|
||||||
|
# catch ConnectorExceptions.SessionWindowNotExistError
|
||||||
|
except ConnectorExceptions.SessionWindowNotExistError as e:
|
||||||
|
lRDPConfigurationDict["SessionIsWindowExistBool"] = False # Set flag that session is disconnected
|
||||||
|
# Write in logger - warning
|
||||||
|
lLogger.warning(
|
||||||
|
f"SessionHex: {str(lRDPConfigurationDict['SessionHex'])}:: Session is not exist!")
|
||||||
|
# general exceptions
|
||||||
|
except Exception as e:
|
||||||
|
# Write in logger - warning
|
||||||
|
lLogger.exception(f"!!! ATTENTION !!! Unrecognized error")
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# Safe turn off the - no need because of Orchestrator control
|
||||||
|
#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
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
Connector.SystemRDPWarningClickOk() # Click all warning messages
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# Check if RDP session is full screen (if is not ignored)
|
||||||
|
if inGlobalDict["FullScreenRDPSessionKeyStr"] is not None:
|
||||||
|
lRDPSessionKeyStr = inGlobalDict["FullScreenRDPSessionKeyStr"] # Get the RDPSessionKeyStr
|
||||||
|
if lRDPSessionKeyStr in inGlobalDict["RDPList"]: # Session Key is in dict
|
||||||
|
lRDPConfigurationDict = inGlobalDict["RDPList"][lRDPSessionKeyStr]
|
||||||
|
#if not lRDPConfigurationDict["SessionIsIgnoredBool"]: # Session is not ignored
|
||||||
|
# Check if full screen
|
||||||
|
lIsFullScreenBool = Connector.SessionIsFullScreen(inSessionHexStr=lRDPConfigurationDict["SessionHex"])
|
||||||
|
if not lIsFullScreenBool: # If not the full screen
|
||||||
|
# Check all RDP window and minimize it
|
||||||
|
for lRDPSessionKeyStrItem in inGlobalDict["RDPList"]:
|
||||||
|
lRDPConfigurationDictItem = inGlobalDict["RDPList"][lRDPSessionKeyStrItem]
|
||||||
|
if Connector.SessionIsFullScreen(inSessionHexStr=lRDPConfigurationDictItem["SessionHex"]):
|
||||||
|
Connector.SessionScreenSize_X_Y_W_H(inSessionHex=lRDPConfigurationDictItem["SessionHex"], inXInt=10, inYInt=10,
|
||||||
|
inWInt=550,
|
||||||
|
inHInt=350) # Prepare little window
|
||||||
|
# Set full screen for new window
|
||||||
|
Connector.SessionScreenFull(inSessionHex=lRDPConfigurationDict["SessionHex"])
|
||||||
|
else:
|
||||||
|
# Check all RDP window and minimize it
|
||||||
|
for lRDPSessionKeyStrItem in inGlobalDict["RDPList"]:
|
||||||
|
lRDPConfigurationDictItem = inGlobalDict["RDPList"][lRDPSessionKeyStrItem]
|
||||||
|
if Connector.SessionIsFullScreen(inSessionHexStr=lRDPConfigurationDictItem["SessionHex"]):
|
||||||
|
Connector.SessionScreenSize_X_Y_W_H(inSessionHex=lRDPConfigurationDictItem["SessionHex"],
|
||||||
|
inXInt=10, inYInt=10,
|
||||||
|
inWInt=550,
|
||||||
|
inHInt=350) # Prepare little window
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
# Iterate the activity list in robot RDP active
|
||||||
|
lActivityListNew = []
|
||||||
|
lActivityListOld = inGlobalDict["ActivityList"]
|
||||||
|
inGlobalDict["ActivityList"] = []
|
||||||
|
for lActivityItem in lActivityListOld:
|
||||||
|
lSubmoduleFunctionName = lActivityItem["DefNameStr"]
|
||||||
|
if lSubmoduleFunctionName in dir(Processor):
|
||||||
|
# Run SettingUpdate function in submodule
|
||||||
|
# mGlobalDict = getattr(lTechModuleFromSpec, lSubmoduleFunctionName)()
|
||||||
|
lActivityItemResult = getattr(Processor, 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["ActivityList"] = lActivityListNew # Override the value
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
except RuntimeError as e:
|
||||||
|
# case noGUI error passed - do nothing
|
||||||
|
# Write in logger - warning
|
||||||
|
lLogger.warning(f"Host session has lost the GUI")
|
||||||
|
finally:
|
||||||
|
# Wait for the next iteration
|
||||||
|
time.sleep(0.7)
|
||||||
|
# Scheduler.Scheduler(mGSettingsRDPActiveDict["Scheduler"]) # Init & Run Scheduler TODO remake in processor list
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
#Monitor.Monitor(mGSettingsRDPActiveDict, 1)
|
||||||
|
except Exception as e:
|
||||||
|
# Write in logger - warning
|
||||||
|
lLogger.exception(f"!!! ATTENTION !!! Global error handler - look at code")
|
@ -1,7 +1,6 @@
|
|||||||
from . import Timer # Async thread
|
from . import Timer # Async thread
|
||||||
import threading # Create in another thread
|
import threading # Create in another thread
|
||||||
import datetime # Datetime class
|
import datetime # Datetime class
|
||||||
import copy # Copy struct functions
|
|
||||||
import time # time functions
|
import time # time functions
|
||||||
import importlib # import lib functions
|
import importlib # import lib functions
|
||||||
# Scheduler class - init and work by the configuration
|
# Scheduler class - init and work by the configuration
|
@ -1,76 +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
|
|
||||||
#ATTENTION
|
|
||||||
gSettings = None # Gsettings will be initialized after the import module
|
|
||||||
def ProcessStartIfNotRunning(inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
|
|
||||||
global gSettings
|
|
||||||
inGlobalDict = gSettings
|
|
||||||
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"Defs_SessionIndex.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(inSessionIndex, inProcessName, inFlagForceClose):
|
|
||||||
global gSettings
|
|
||||||
inGlobalDict = gSettings
|
|
||||||
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"Defs_SessionIndex.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(inSessionIndex, inHostFilePath, inRDPFilePath):
|
|
||||||
global gSettings
|
|
||||||
inGlobalDict = gSettings
|
|
||||||
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"Defs_SessionIndex.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(inSessionIndex, inRDPFilePath, inHostFilePath):
|
|
||||||
global gSettings
|
|
||||||
inGlobalDict = gSettings
|
|
||||||
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"Defs_SessionIndex.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