From: Anthony Geay Date: Wed, 23 Feb 2022 09:45:52 +0000 (+0100) Subject: Management of salome -t X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0519f7de0e74b54c98b2b13a637193b55fe40632;p=modules%2Fkernel.git Management of salome -t --- diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 5375452df..04e6939f6 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -65,6 +65,8 @@ import psutil from salome_utils import (generateFileName, getHostName, getLogDir, getShortHostName, getUserName, killOmniNames, killPid, verbose) +import logging +logger = logging.getLogger() def getPiDict(port, appname='salome', full=True, hidden=True, hostname=None): """ @@ -247,6 +249,7 @@ def __killPids(pids): processes = [] for pid in pids: try: + logger.debug("Add process with PID = {} into PIDList to kill".format(pid)) processes.append(psutil.Process(pid)) except psutil.NoSuchProcess: if verbose(): @@ -262,7 +265,7 @@ def __killMyPort(port, filedict): # ensure port is an integer with suppress(ValueError): port = int(port) - + logger.debug("Into __killMyPort with port {}. File containing PID to kill is {}".format(port,filedict)) # read pids from pidict file with suppress(Exception), open(filedict, 'rb') as fpid: pids_lists = pickle.load(fpid) diff --git a/bin/runSalome.py b/bin/runSalome.py index 20f3da436..76ab5872f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -80,6 +80,7 @@ def startSalome(args, modules_list, modules_root_dir): mySessionServ.setpath(modules_list,modules_root_dir) mySessionServ.run() ior_fakens_filename = mySessionServ.iorfakens + logger.debug("Rendez-vous file for to retrieve IOR of session is \"{}\"".format(ior_fakens_filename)) end_time = os.times() @@ -174,7 +175,7 @@ def addToPidict(args): global process_id from addToKillList import addToKillList for pid, cmd in list(process_id.items()): - addToKillList(pid, cmd, args['port']) + addToKillList(pid, cmd) # ----------------------------------------------------------------------------- @@ -187,6 +188,26 @@ def main(exeName=None): # -- setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env) ior_fakens_filename = useSalome(args, modules_list, modules_root_dir) + ### + toimport = [] + if 'gui' in args and 'session_gui' in args: + if not args['gui'] or not args['session_gui']: + if 'study_hdf' in args: + toopen = args['study_hdf'] + if toopen: + import salome + salome.salome_init(path=toopen) + if 'pyscript' in args: + toimport = args['pyscript'] + from salomeContextUtils import formatScriptsAndArgs + from addToKillList import addToKillList + command = formatScriptsAndArgs(toimport, escapeSpaces=True) + if command: + logger.debug("Launching following shell command : {}".format(str(command))) + proc = subprocess.Popen(command, shell=True) + addToKillList(proc.pid, command) + res = proc.wait() + if res: sys.exit(1) return args, ior_fakens_filename # ----------------------------------------------------------------------------- @@ -273,12 +294,14 @@ def foreGround(args, ior_fakens_filename): status = session.GetStatSession() assert status.activeGUI except Exception: + logger.debug("Process of the session under monitoring {} has vanished !".format(session_pid)) break from time import sleep sleep(dt) pass pass except KeyboardInterrupt: + logger.debug("Keyboard requested : killing all process attached to port {}".format(port)) from killSalomeWithPort import killMyPortSSL killMyPortSSL(port) pass diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 3cdc0c0a0..6597d9a5f 100755 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -353,6 +353,7 @@ class SalomeContext: args = [] # Initialize SALOME environment sys.argv = ['runSalomeOld'] + args + print(477*"!"+str(sys.argv)) import setenv setenv.main(True, exeName="salome withsession") @@ -365,9 +366,10 @@ class SalomeContext: if args is None: args = [] sys.argv = ['runSalome'] + args + print(477*"@"+str(sys.argv)) import setenv setenv.main(True, exeName="salome withsession") - + import runSalome runSalome.runSalome() return 0