# After testing - ready for stage

dev-linux
Ivan Maslov 5 years ago
parent f4ed1ff981
commit 31e2d1a08c

@ -10,6 +10,7 @@ import keyboard # Keyboard functions
import time import time
import random # random integers import random # random integers
from win32api import GetSystemMetrics # Get Screen rect from win32api import GetSystemMetrics # Get Screen rect
import pyautogui # for hotkey operations
# System variables for recovery scenario # System variables for recovery scenario
gRecoveryWindowRDPRetryCountInt = 3 # Retry iteration count is RDP window is not responsible gRecoveryWindowRDPRetryCountInt = 3 # Retry iteration count is RDP window is not responsible
gRecoveryWindowRDPRetryIntervalSecInt = 3 # Retry interval for reconnect gRecoveryWindowRDPRetryIntervalSecInt = 3 # Retry interval for reconnect
@ -34,7 +35,7 @@ gRecoveryCMDResponsibleRetryIntervalSecInt = 3 # Retry interval for retry
} }
} }
""" """
def Session(inRDPSessionConfiguration): def Session(inRDPSessionConfiguration, inScreenSize550x350Bool = False):
#RDPConnector.SessionConnect(mConfiguration) #RDPConnector.SessionConnect(mConfiguration)
#RDPConnector.LoginPassSet("111.222.222.111","ww","dd") #RDPConnector.LoginPassSet("111.222.222.111","ww","dd")
(lRDPFile, lSessionHex) = SessionConfigurationCreate(inRDPSessionConfiguration) (lRDPFile, lSessionHex) = SessionConfigurationCreate(inRDPSessionConfiguration)
@ -43,7 +44,7 @@ def Session(inRDPSessionConfiguration):
#Set login/password #Set login/password
SessionLoginPasswordSet(inRDPSessionConfiguration["Host"],inRDPSessionConfiguration["Login"],inRDPSessionConfiguration["Password"]) SessionLoginPasswordSet(inRDPSessionConfiguration["Host"],inRDPSessionConfiguration["Login"],inRDPSessionConfiguration["Password"])
#Start session #Start session
SessionRDPStart(lRDPFile) SessionRDPStart(lRDPFile, inScreenSize550x350Bool= inScreenSize550x350Bool)
#Remove temp file #Remove temp file
time.sleep(4) #Delete file after some delay - one way to delete and run the RDP before because RDP is not read file in one moment time.sleep(4) #Delete file after some delay - one way to delete and run the RDP before because RDP is not read file in one moment
os.remove(lRDPFile) # delete the temp rdp os.remove(lRDPFile) # delete the temp rdp
@ -89,7 +90,7 @@ def SessionConfigurationCreate(inConfiguration):
#Return .rdp full path #Return .rdp full path
return (lRDPCurrentFileFullPath, (lRDPCurrentFileFullPath.split("\\")[-1])[0:-4]) return (lRDPCurrentFileFullPath, (lRDPCurrentFileFullPath.split("\\")[-1])[0:-4])
#RDPSessionStart #RDPSessionStart
def SessionRDPStart(inRDPFilePath): def SessionRDPStart(inRDPFilePath, inScreenSize550x350Bool = False):
#Disable certificate warning #Disable certificate warning
lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 0 /f' lCMDString = 'reg add "HKEY_CURRENT_USER\\Software\\Microsoft\\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 0 /f'
os.system(lCMDString) os.system(lCMDString)
@ -147,24 +148,27 @@ def SessionRDPStart(inRDPFilePath):
# Raise exception if RDP is not active # Raise exception if RDP is not active
if len(lWaitResult) == 0: if len(lWaitResult) == 0:
raise ConnectorExceptions.SessionWindowNotExistError("Error when initialize the RDP session - No RDP windows has appreared!") raise ConnectorExceptions.SessionWindowNotExistError("Error when initialize the RDP session - No RDP windows has appreared!")
# Wait for init time.sleep(3) # Wait for init
time.sleep(3) if inScreenSize550x350Bool: SessionScreenSize_X_Y_W_H(inSessionHex = lRDPFileName, inXInt = 10, inYInt = 10, inWInt = 550, inHInt = 350) #Prepare little window
SessionScreenSize_X_Y_W_H(inSessionHex = lRDPFileName, inXInt = 10, inYInt = 10, inWInt = 550, inHInt = 350) #Prepare little window
return None return None
#Set fullscreen for app #Set fullscreen for app
def SessionScreenFull(inSessionHex, inGSettings = None): def SessionScreenFull(inSessionHex, inLogger = None, inRDPConfigurationItem = None):
######################################## ########################################
lWindowRDPRetryIterator = 0 # Retry iterator if RDP window is not active lWindowRDPRetryIterator = 0 # Retry iterator if RDP window is not active
lRDPConfigurationItem = None lRDPConfigurationItem = inRDPConfigurationItem # Get the RDP configuration item
lL = None lL = inLogger # Get the logger instance
if inGSettings: # Get the values from gSettings lRDPWindow = None # Init the variable
lRDPConfigurationItem = inGSettings["RobotRDPActive"]["RDPList"][inSessionHex] # Get the RDP configuration item
lL = inGSettings["Logger"] # Get the logger instance
while lWindowRDPRetryIterator<gRecoveryWindowRDPRetryCountInt: # Loop iteration to connect to RDP while lWindowRDPRetryIterator<gRecoveryWindowRDPRetryCountInt: # Loop iteration to connect to RDP
try: # Try to get RDP window try: # Try to get RDP window
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}]) lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}])
lWindowRDPRetryIterator = gRecoveryWindowRDPRetryCountInt # Set last iterator to turn off the loop lWindowRDPRetryIterator = gRecoveryWindowRDPRetryCountInt # Set last iterator to turn off the loop
# RDP window has been detected - go to set focus and maximize
lRDPWindow.set_focus()
lRDPWindow.maximize()
if not SessionIsFullScreen(inSessionHex):
lRDPWindow.type_keys("^%{BREAK}")
time.sleep(0.5)
except Exception as e: # RDP window is not exist - try to reconnect except Exception as e: # RDP window is not exist - try to reconnect
if lL: lL.warning(f"RDP::SessionScreenFull: RDP window is not exist - try sleep {gRecoveryWindowRDPRetryIntervalSecInt}[s.] and then to reconnect. SessionHex: {inSessionHex}. Current retry iterator is {lWindowRDPRetryIterator}") if lL: lL.warning(f"RDP::SessionScreenFull: RDP window is not exist - try sleep {gRecoveryWindowRDPRetryIntervalSecInt}[s.] and then to reconnect. SessionHex: {inSessionHex}. Current retry iterator is {lWindowRDPRetryIterator}")
if lRDPConfigurationItem: if lRDPConfigurationItem:
@ -172,6 +176,8 @@ def SessionScreenFull(inSessionHex, inGSettings = None):
# Try to reconnect the RDP # Try to reconnect the RDP
SessionClose(inSessionHexStr=inSessionHex) # Close the SessionClose(inSessionHexStr=inSessionHex) # Close the
Session(lRDPConfigurationItem) # Create RDP session Session(lRDPConfigurationItem) # Create RDP session
inSessionHex = lRDPConfigurationItem["SessionHex"] # Get new session hex after reconnect
SystemRDPWarningClickOk() # Click all warning messages
lWindowRDPRetryIterator = lWindowRDPRetryIterator + 1 # increase the iterator lWindowRDPRetryIterator = lWindowRDPRetryIterator + 1 # increase the iterator
if lWindowRDPRetryIterator >= gRecoveryWindowRDPRetryCountInt: # Raise the error if retry count is over if lWindowRDPRetryIterator >= gRecoveryWindowRDPRetryCountInt: # Raise the error if retry count is over
if lL: lL.warning(f"RDP::SessionScreenFull: Retry count is over. Raise the error. SessionHex: {inSessionHex}.") # Log the info if lL: lL.warning(f"RDP::SessionScreenFull: Retry count is over. Raise the error. SessionHex: {inSessionHex}.") # Log the info
@ -179,13 +185,6 @@ def SessionScreenFull(inSessionHex, inGSettings = None):
else: else:
if lL: lL.warning(f"RDP::SessionScreenFull: Has no RDP configuration item - don't reconnect. Raise the error. SessionHex: {inSessionHex}") # Log the info if lL: lL.warning(f"RDP::SessionScreenFull: Has no RDP configuration item - don't reconnect. Raise the error. SessionHex: {inSessionHex}") # Log the info
raise ConnectorExceptions.SessionWindowNotExistError() # raise the error raise ConnectorExceptions.SessionWindowNotExistError() # raise the error
# RDP window has been detected - go to set focus and maximize
lRDPWindow.set_focus()
lRDPWindow.maximize()
#time.sleep(0.5)
if not SessionIsFullScreen(inSessionHex):
lRDPWindow.type_keys("^%{BREAK}")
time.sleep(0.5)
return None return None
# Set the screen size # Set the screen size
@ -233,16 +232,14 @@ def SessionClose(inSessionHexStr):
# "IsResponsibleBool": True|False # Flag is RDP is responsible - works only when inModeStr = CROSSCHECK # "IsResponsibleBool": True|False # Flag is RDP is responsible - works only when inModeStr = CROSSCHECK
# } # }
# example Connector.SessionCMDRun("4d1e48f3ff6c45cc810ea25d8adbeb50","start notepad", "RUN") # example Connector.SessionCMDRun("4d1e48f3ff6c45cc810ea25d8adbeb50","start notepad", "RUN")
def SessionCMDRun(inSessionHex,inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboardTimeoutSec = 5, inGSettings = None): def SessionCMDRun(inSessionHex,inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboardTimeoutSec = 5, inLogger=None, inRDPConfigurationItem=None):
lL = None # Init the logger lL = inLogger # Init the logger
if inGSettings: # If gSettings is exist
lL = inGSettings["Logger"] # get the logger
# Init the result dict # Init the result dict
lResult = {"OutStr": None,"IsResponsibleBool":True} lResult = {"OutStr": None,"IsResponsibleBool":True}
SessionScreenFull(inSessionHex, inGSettings = inGSettings) # Enter full screen mode with recovery scenario SessionScreenFull(inSessionHex, inLogger=lL, inRDPConfigurationItem=inRDPConfigurationItem) # Enter full screen mode with recovery scenario
time.sleep(2) time.sleep(2)
# Run CMD operations # Run CMD operations
lResult = SystemCMDRun(inCMDCommandStr = inCMDCommandStr, inModeStr = inModeStr, inClipboardTimeoutSec = inClipboardTimeoutSec, inLogger=lL) lResult = SystemCMDRun(inSessionHexStr = inRDPConfigurationItem["SessionHex"], inCMDCommandStr = inCMDCommandStr, inModeStr = inModeStr, inClipboardTimeoutSec = inClipboardTimeoutSec, inLogger=lL)
# Exit fullscreen mode # Exit fullscreen mode
SessionScreenSize_X_Y_W_H(inSessionHex=inSessionHex, inXInt=10, inYInt=10, inWInt=550, SessionScreenSize_X_Y_W_H(inSessionHex=inSessionHex, inXInt=10, inYInt=10, inWInt=550,
inHInt=350) # Prepare little window inHInt=350) # Prepare little window
@ -294,7 +291,12 @@ def SessionIsMinimizedScreen(inSessionHexStr):
# "IsResponsibleBool": True|False # Flag is RDP is responsible - works only when inModeStr = CROSSCHECK # "IsResponsibleBool": True|False # Flag is RDP is responsible - works only when inModeStr = CROSSCHECK
# } # }
# example Connector.SessionCMDRun("4d1e48f3ff6c45cc810ea25d8adbeb50","start notepad", "RUN") # example Connector.SessionCMDRun("4d1e48f3ff6c45cc810ea25d8adbeb50","start notepad", "RUN")
def SystemCMDRun(inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboardTimeoutSec = 5, inLogger = None): def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboardTimeoutSec = 5, inLogger = None):
lRDPWindow = None # Init the UI object
try:
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHexStr}.*", "backend": "win32"}])
except Exception as e:
raise ConnectorExceptions.SessionWindowNotExistError() # Raise error of gui window
lL = inLogger # Alias for logger lL = inLogger # Alias for logger
lResult = {"OutStr": None,"IsResponsibleBool":True} # Init the result dict lResult = {"OutStr": None,"IsResponsibleBool":True} # Init the result dict
lClipboardTextOld = str(random.randrange(999,9999999)) # Set random text to clipboard (for check purposes that clipboard text has been changed) lClipboardTextOld = str(random.randrange(999,9999999)) # Set random text to clipboard (for check purposes that clipboard text has been changed)
@ -307,18 +309,19 @@ def SystemCMDRun(inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboard
while lRecoveryWindowRUNRetryIteratorInt<gRecoveryWindowRUNRetryCountInt: # loop for retry while lRecoveryWindowRUNRetryIteratorInt<gRecoveryWindowRUNRetryCountInt: # loop for retry
lCMDPostFixStr = "" # Case default "RUN" lCMDPostFixStr = "" # Case default "RUN"
if inModeStr == "CROSSCHECK": if inModeStr == "CROSSCHECK":
lCMDPostFixStr = f"| echo {lCrosscheckKeyStr} | clip" lCMDPostFixStr = f"& (echo {lCrosscheckKeyStr} | clip)"
elif inModeStr == "LISTEN": elif inModeStr == "LISTEN":
lCMDPostFixStr = f"| clip" lCMDPostFixStr = f"| clip"
keyboard.press_and_release('win+r') keyboard.press_and_release('win+r')
time.sleep(1) # Wait for RUN window will appear time.sleep(1) # Wait for RUN window will appear
keyboard.press_and_release("ctrl+a") # Select all lRDPWindow.type_keys("^(a)") # Select all
keyboard.press_and_release("backspace") # Delete selected all keyboard.press_and_release("backspace") # Delete selected all
lInputStr = f"cmd /c {inCMDCommandStr} {lCMDPostFixStr}" # Generate the output string for RUN window time.sleep(0.5) # Wait for RUN window will appear ctrl+a+backspace is async - so we need some timeout...
lInputStr = f"cmd /c ({inCMDCommandStr}) {lCMDPostFixStr}" # Generate the output string for RUN window
keyboard.write(lInputStr) # Write new text keyboard.write(lInputStr) # Write new text
keyboard.press_and_release("ctrl+a") # Select all time.sleep(0.5)
keyboard.press_and_release("ctrl+c") # COPY in clipboard to check lRDPWindow.type_keys("^(a)") # Select all
#time.sleep(2 + 2 * lRecoveryWindowRUNRetryIteratorInt) # Wait when data will be copied UPD - no need - wait is below lRDPWindow.type_keys("^(c)") # Copy data
# Check the clipboard # Check the clipboard
lClipboardWaitTimeStartSec = time.time() lClipboardWaitTimeStartSec = time.time()
lClipboardStr = Clipboard.TextGet() # Get text from clipboard lClipboardStr = Clipboard.TextGet() # Get text from clipboard
@ -370,8 +373,8 @@ def SystemCMDRun(inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK", inClipboard
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
return lResult # return the result return lResult # return the result
# Check if current RDP is responsible # Check if current RDP is responsible
def SystemRDPIsResponsible(): def SystemRDPIsResponsible(inSessionHexStr):
return SystemCMDRun(inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK")["IsResponsibleBool"] return SystemCMDRun(inSessionHexStr = inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCHECK")["IsResponsibleBool"]
# Click OK on error messages # Click OK on error messages
def SystemRDPWarningClickOk(): def SystemRDPWarningClickOk():
# Try to click OK Error window in RUS version # Try to click OK Error window in RUS version

@ -30,10 +30,9 @@ def RDPSessionConnect(inRDPSessionKeyStr, inHostStr, inPortStr, inLoginStr, inPa
"SessionIsWindowResponsibleBool": False, # Flag if RDP window is responsible (recieve commands). Check every nn seconds. If window is Responsible - window is Exist too , 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 "SessionIsIgnoredBool": False # Flag to ignore RDP window False - dont ignore, True - ignore, example False
} }
# Add item in RDPList gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr] = lRDPConfigurationItem # Add item in RDPList
gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr] = lRDPConfigurationItem Connector.Session(lRDPConfigurationItem) # Create the RDP session
# Create the RDP session Connector.SystemRDPWarningClickOk() # Click all warning messages
Connector.Session(lRDPConfigurationItem)
return True return True
# Disconnect the RDP session # Disconnect the RDP session
@ -43,6 +42,7 @@ def RDPSessionDisconnect(inRDPSessionKeyStr):
if lSessionHex: if lSessionHex:
gSettings["RobotRDPActive"]["RDPList"].pop(inRDPSessionKeyStr,None) gSettings["RobotRDPActive"]["RDPList"].pop(inRDPSessionKeyStr,None)
Connector.SessionClose(inSessionHexStr=lSessionHex) Connector.SessionClose(inSessionHexStr=lSessionHex)
Connector.SystemRDPWarningClickOk() # Click all warning messages
return True return True
# RDP Session reconnect # RDP Session reconnect
@ -64,18 +64,19 @@ def RDPSessionLogoff(inRDPSessionKeyStr):
# Calculate the session Hex # Calculate the session Hex
lSessionHex = gSettings["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None) lSessionHex = gSettings["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None)
if lSessionHex: if lSessionHex:
gSettings["RobotRDPActive"]["RDPList"].pop(inRDPSessionKeyStr,None)
# Run CMD # Run CMD
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN", inGSettings = gSettings) Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="CROSSCHECK", inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
gSettings["RobotRDPActive"]["RDPList"].pop(inRDPSessionKeyStr,None) # Remove item from RDPList
return lResult return lResult
# Check RDP Session responsibility TODO NEED DEV + TEST # Check RDP Session responsibility TODO NEED DEV + TEST
def RDPSessionResponsibilityCheck(inRDPSessionKeyStr): def RDPSessionResponsibilityCheck(inRDPSessionKeyStr):
global gSettings global gSettings
inGlobalDict = gSettings inGlobalDict = gSettings
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]["SessionHex"] lRDPConfigurationItem = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr] # Get the alias
# set the fullscreen # set the fullscreen
Connector.SessionScreenFull(inSessionHex=lSessionHex, inGSettings = gSettings) # ATTENTION!!! Session hex can be updated!!!
Connector.SessionScreenFull(inSessionHex=lRDPConfigurationItem["SessionHex"], inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
time.sleep(1) time.sleep(1)
# Check RDP responsibility # Check RDP responsibility
lDoCheckResponsibilityBool = True lDoCheckResponsibilityBool = True
@ -87,7 +88,7 @@ def RDPSessionResponsibilityCheck(inRDPSessionKeyStr):
pass pass
#raise ConnectorExceptions.SessionWindowNotResponsibleError("Error when initialize the RDP session - RDP window is not responding!") #raise ConnectorExceptions.SessionWindowNotResponsibleError("Error when initialize the RDP session - RDP window is not responding!")
# Check responding # Check responding
lDoCheckResponsibilityBool = not Connector.SystemRDPIsResponsible() lDoCheckResponsibilityBool = not Connector.SystemRDPIsResponsible(inSessionHexStr = lRDPConfigurationItem["SessionHex"])
# Wait if is not responding # Wait if is not responding
if lDoCheckResponsibilityBool: if lDoCheckResponsibilityBool:
time.sleep(3) time.sleep(3)
@ -105,7 +106,7 @@ def RDPSessionProcessStartIfNotRunning(inRDPSessionKeyStr, inProcessNameWEXEStr,
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None) lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None)
# Run CMD # Run CMD
if lSessionHex: if lSessionHex:
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN", inGSettings = gSettings) Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="CROSSCHECK", inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
return lResult return lResult
# Create CMD str to stop process # Create CMD str to stop process
def RDPSessionProcessStop(inRDPSessionKeyStr, inProcessNameWEXEStr, inFlagForceCloseBool): def RDPSessionProcessStop(inRDPSessionKeyStr, inProcessNameWEXEStr, inFlagForceCloseBool):
@ -119,7 +120,7 @@ def RDPSessionProcessStop(inRDPSessionKeyStr, inProcessNameWEXEStr, inFlagForceC
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None) lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None)
# Run CMD # Run CMD
if lSessionHex: if lSessionHex:
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN", inGSettings = gSettings) Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="CROSSCHECK", inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
return lResult return lResult
# Send file from Host to Session RDP using shared drive in RDP # Send file from Host to Session RDP using shared drive in RDP
def RDPSessionFileStoredSend(inRDPSessionKeyStr, inHostFilePathStr, inRDPFilePathStr): def RDPSessionFileStoredSend(inRDPSessionKeyStr, inHostFilePathStr, inRDPFilePathStr):
@ -132,7 +133,7 @@ def RDPSessionFileStoredSend(inRDPSessionKeyStr, inHostFilePathStr, inRDPFilePat
#lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]["SessionHex"] #lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr]["SessionHex"]
# Run CMD # Run CMD
if lSessionHex: if lSessionHex:
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120, inGSettings = gSettings) Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120, inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
return lResult return lResult
# Recieve file from Session RDP to Host using shared drive in RDP # Recieve file from Session RDP to Host using shared drive in RDP
def RDPSessionFileStoredRecieve(inRDPSessionKeyStr, inRDPFilePathStr, inHostFilePathStr): def RDPSessionFileStoredRecieve(inRDPSessionKeyStr, inRDPFilePathStr, inHostFilePathStr):
@ -144,5 +145,5 @@ def RDPSessionFileStoredRecieve(inRDPSessionKeyStr, inRDPFilePathStr, inHostFile
lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None) lSessionHex = inGlobalDict["RobotRDPActive"]["RDPList"].get(inRDPSessionKeyStr,{}).get("SessionHex", None)
# Run CMD # Run CMD
if lSessionHex: if lSessionHex:
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120, inGSettings = gSettings) Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="LISTEN", inClipboardTimeoutSec = 120, inLogger=gSettings["Logger"], inRDPConfigurationItem=gSettings["RobotRDPActive"]["RDPList"][inRDPSessionKeyStr])
return lResult return lResult

@ -46,7 +46,7 @@ def RobotRDPActive(inGSettings):
# Check if RDP window is not ignored # Check if RDP window is not ignored
if not lRDPConfigurationDict["SessionIsIgnoredBool"]: if not lRDPConfigurationDict["SessionIsIgnoredBool"]:
try: try:
Connector.Session(lRDPConfigurationDict) Connector.Session(lRDPConfigurationDict, inScreenSize550x350Bool = True)
lRDPConfigurationDict["SessionIsWindowExistBool"] = True # Flag that session is started lRDPConfigurationDict["SessionIsWindowExistBool"] = True # Flag that session is started
if lL: lL.info(f"SessionHex: {str(lRDPConfigurationDict['SessionHex'])}:: Session has been initialized!") #Logging if lL: lL.info(f"SessionHex: {str(lRDPConfigurationDict['SessionHex'])}:: Session has been initialized!") #Logging
# catch ConnectorExceptions.SessionWindowNotExistError # catch ConnectorExceptions.SessionWindowNotExistError
@ -90,7 +90,7 @@ def RobotRDPActive(inGSettings):
inWInt=550, inWInt=550,
inHInt=350) # Prepare little window inHInt=350) # Prepare little window
# Set full screen for new window # Set full screen for new window
Connector.SessionScreenFull(inSessionHex=lRDPConfigurationDict["SessionHex"], inGSettings = inGSettings) Connector.SessionScreenFull(inSessionHex=lRDPConfigurationDict["SessionHex"], inLogger= inGSettings["Logger"], inRDPConfigurationItem=inGlobalDict["RDPList"][lRDPSessionKeyStrItem])
else: else:
# Check all RDP window and minimize it # Check all RDP window and minimize it
for lRDPSessionKeyStrItem in inGlobalDict["RDPList"]: for lRDPSessionKeyStrItem in inGlobalDict["RDPList"]:
@ -108,12 +108,13 @@ def RobotRDPActive(inGSettings):
for lActivityItem in lActivityListOld: for lActivityItem in lActivityListOld:
lSubmoduleFunctionName = lActivityItem["DefNameStr"] lSubmoduleFunctionName = lActivityItem["DefNameStr"]
if lSubmoduleFunctionName in dir(Processor): if lSubmoduleFunctionName in dir(Processor):
lActivityItemResult = None # init the variable
try: # try to run function from Processor.py try: # try to run function from Processor.py
lActivityItemResult = getattr(Processor, lSubmoduleFunctionName)( lActivityItemResult = getattr(Processor, lSubmoduleFunctionName)(
*lActivityItem["ArgList"], **lActivityItem["ArgDict"]) *lActivityItem["ArgList"], **lActivityItem["ArgDict"])
except Exception as e: except Exception as e:
if lL: lL.exception(f"RDP::main: Exception when run def in processor.py - activity will be ignored. Activity item: {lActivityItem}") #Logging if lL: lL.exception(f"RDP::main: Exception when run def in processor.py - activity will be ignored. Activity item: {lActivityItem}") #Logging
lActivityItemResultType = True # True - clear from repeat list lActivityItemResult = True # True - clear from repeat list
lActivityItemResultType = type(lActivityItemResult) lActivityItemResultType = type(lActivityItemResult)
# Check if Result is bool # Check if Result is bool
if lActivityItemResultType is bool: if lActivityItemResultType is bool:

Loading…
Cancel
Save