iflClipboardStr==lInputStr:# Cross check the clipboard data and input string
lRecoveryWindowRUNRetryIteratorInt=gRecoveryWindowRUNRetryCountInt# Set final count to block the loop
else:# Failed - wait and retry
iflL:lL.warning(f"RDP::SystemCMDRun: Window run doesn't appear. Wait for {gRecoveryWindowRUNRetryIntervalSecInt}[s.] and retry. Current retry iterator is {lRecoveryWindowRUNRetryIteratorInt}. CMD Str: {lInputStr}")# Log the error
iflL:lL.warning(f"RDP::SystemCMDRun: RUN window (win+r) doesn't appear. Wait for {gRecoveryWindowRUNRetryIntervalSecInt}[s.] and retry. Current retry iterator is {lRecoveryWindowRUNRetryIteratorInt}. CMD Str: {lInputStr}")# Log the error
lRecoveryWindowRUNRetryIteratorInt=lRecoveryWindowRUNRetryIteratorInt+1# Increment the iterator
lResult["OutStr"]=Clipboard.TextGet()# Get text from clipboard
time.sleep(0.5)# wait some time for the next operation
iflResult["OutStr"]==lClipboardTextOld:# If value hasn't been changed - retry send
lRecoveryCMDResponsibleRetryIteratorInt=lRecoveryCMDResponsibleRetryIteratorInt+1# increment the iterator
iflL:lL.warning(f"RDP::SystemCMDRun: CMD command doesn't been executed (no changes in clipboard data). Wait for {gRecoveryCMDResponsibleRetryIntervalSecInt}[s.] and retry from start window RUN. Current retry iterator is {lRecoveryCMDResponsibleRetryIteratorInt}. CMD Str: {lInputStr}, Clipboard data: {lResult['OutStr']}")# Log the error
iflRecoveryCMDResponsibleRetryIteratorInt>=gRecoveryCMDResponsibleRetryCountInt:# raise the error if retry count is exceeded
iflL:lL.warning(f"RDP::SystemCMDRun: Retry count is over. Raise the error.")# Log the error
iflL:lL.warning(f"RDP::SystemCMDRun: CMD command retry count is over. Raise the error.")# Log the error
raiseConnectorExceptions.CMDResponsibleError()# Raise the error
time.sleep(gRecoveryCMDResponsibleRetryIntervalSecInt)# wait for some seconds before new iteration
lRecoveryCMDResponsibleRetryIteratorInt=lRecoveryCMDResponsibleRetryIteratorInt+1# increment the iterator
iflL:lL.warning(f"RDP::SystemCMDRun: CMD command doesn't been executed (wrong clipboard data). Wait for {gRecoveryCMDResponsibleRetryIntervalSecInt}[s.] and retry from start window RUN. Current retry iterator is {lRecoveryCMDResponsibleRetryIteratorInt}. CMD Str: {lInputStr}, Clipboard data: {lResult['OutStr']}")# Log the error
iflRecoveryCMDResponsibleRetryIteratorInt>=gRecoveryCMDResponsibleRetryCountInt:# raise the error if retry count is exceeded
iflL:lL.warning(f"RDP::SystemCMDRun: Retry count is over. Raise the error.")# Log the error
iflL:lL.warning(f"RDP::SystemCMDRun: CMD command retry count is over. Raise the error.")# Log the error
raiseConnectorExceptions.CMDResponsibleError()# Raise the error
time.sleep(gRecoveryCMDResponsibleRetryIntervalSecInt)# wait for some seconds before new iteration
else:# clipboard data has been changed but mode is not crosscheck - return success from function
ifConnector.SessionIsFullScreen(inSessionHexStr=lRDPConfigurationDictItem["SessionHex"])orConnector.SessionIsMinimizedScreen(inSessionHexStr=lRDPConfigurationDictItem["SessionHex"]):# If window is minimized - restore # if window in full screen - resize