# OpenRPA - hot fixes after the first run

dev-linux
Ivan Maslov 5 years ago
parent fb64808f7a
commit afe13e9417

@ -1,11 +1,13 @@
import os # Get abs path of the file import os # Get abs path of the file
# Create CMD str to run file if process.exe is not running # Create CMD str to run file if process.exe is not running
def ProcessStartIfNotRunning(inProcessName, inFilePath): def ProcessStartIfNotRunning(inProcessName, inFilePath, inFlagGetAbsPath=True):
lFileAbsPath = os.abspath(inFilePath) lFileAbsPath = inFilePath
if inFlagGetAbsPath:
lFileAbsPath = os.path.abspath(inFilePath)
lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})' lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})'
return lResult return lResult
# Create CMD str to stop process # Create CMD str to stop process
def ProcessStop(inProcessName, inFlagForceClose) def ProcessStop(inProcessName, inFlagForceClose):
lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"' lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
if inFlagForceClose: if inFlagForceClose:
lResult+= " /F" lResult+= " /F"

@ -133,6 +133,7 @@ def SessionScreenFull(inSessionHex):
#Prepare little window #Prepare little window
lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}]) lRDPWindow = UIDesktop.UIOSelector_Get_UIO([{"title_re": f"{inSessionHex}.*", "backend": "win32"}])
lRDPWindow.set_focus() lRDPWindow.set_focus()
lRDPWindow.maximize()
if not SessionIsFullScreen(inSessionHex): if not SessionIsFullScreen(inSessionHex):
lRDPWindow.type_keys("^%{BREAK}") lRDPWindow.type_keys("^%{BREAK}")
time.sleep(0.5) time.sleep(0.5)

@ -1,13 +1,14 @@
from . import CMDStr # Create CMD Strings # ATTENTION! HERE IS NO Relative import because it will be imported dynamically
from . import Connector # RDP API from pyOpenRPA.Tools.RobotRDPActive import CMDStr # Create CMD Strings
def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath): from pyOpenRPA.Tools.RobotRDPActive import Connector # RDP API
lCMDStr = CMDStr.ProcessStartIfNotRunning(inProcessName,inFilePath) def ProcessStartIfNotRunning(inGlobalDict, inSessionIndex, inProcessName, inFilePath, inFlagGetAbsPath=True):
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"]
# Run CMD # Run CMD
Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN") Connector.SessionCMDRun(inSessionHex=lSessionHex, inCMDCommandStr=lCMDStr, inModeStr="RUN")
# Create CMD str to stop process # Create CMD str to stop process
def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose) def ProcessStop(inGlobalDict, inSessionIndex, inProcessName, inFlagForceClose):
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"

Loading…
Cancel
Save