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):
"""
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():
# 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)
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()
global process_id
from addToKillList import addToKillList
for pid, cmd in list(process_id.items()):
- addToKillList(pid, cmd, args['port'])
+ addToKillList(pid, cmd)
# -----------------------------------------------------------------------------
# --
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
# -----------------------------------------------------------------------------
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
args = []
# Initialize SALOME environment
sys.argv = ['runSalomeOld'] + args
+ print(477*"!"+str(sys.argv))
import setenv
setenv.main(True, exeName="salome withsession")
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