X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FrunSalome.py;h=fef35cf21c81d3db71d4ae6159b63aecb606404b;hb=38cf5603ef8d480da227b95c8dbc08417bd3a007;hp=f6e76652fe1427cb5edc5ddb99fd734465ea0bd2;hpb=e5867636265822b5e70ca0406c9321ccff264bb0;p=modules%2Fkernel.git diff --git a/bin/runSalome.py b/bin/runSalome.py index f6e76652f..fef35cf21 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -31,11 +31,8 @@ import orbmodule import setenv from launchConfigureParser import verbose from server import process_id, Server - -if sys.platform == "win32": - SEP = ";" -else: - SEP = ":" +import json +import subprocess # ----------------------------------------------------------------------------- @@ -67,7 +64,7 @@ def givenPortKill(port): try: killMyPort(my_port) except: - print "problem in LocalPortKill(), killMyPort("< 0: - self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))] + msg = json.dumps(self.args['pyscript']) + self.SCMD2+=['--pyscript=%s'%(msg)] pass pass pass @@ -430,14 +441,12 @@ def startSalome(args, modules_list, modules_root_dir): if args['wake_up_session']: if "OMNIORB_CONFIG" not in os.environ: from salome_utils import generateFileName - home = os.getenv("HOME") - appli = os.getenv("APPLI") + omniorbUserPath = os.getenv("OMNIORB_USER_PATH") kwargs={} - if appli is not None: - home = os.path.join(os.path.realpath(home), appli,"USERS") - kwargs["with_username"] = True - pass - last_running_config = generateFileName(home, prefix="omniORB", + if omniorbUserPath is not None: + kwargs["with_username"]=True + + last_running_config = generateFileName(omniorbUserPath, prefix="omniORB", suffix="last", extension="cfg", hidden=True, @@ -485,11 +494,8 @@ def startSalome(args, modules_list, modules_root_dir): # Save Naming service port name into # the file args["ns_port_log_file"] if args.has_key('ns_port_log_file'): - home = os.environ['HOME'] - appli= os.environ.get("APPLI") - if appli is not None: - home = os.path.join(os.path.realpath(home), appli, "USERS") - file_name = os.path.join(home, args["ns_port_log_file"]) + omniorbUserPath = os.getenv("OMNIORB_USER_PATH") + file_name = os.path.join(omniorbUserPath, args["ns_port_log_file"]) f = open(file_name, "w") f.write(os.environ['NSPORT']) f.close() @@ -512,6 +518,12 @@ def startSalome(args, modules_list, modules_root_dir): myServer=NotifyServer(args,modules_root_dir) myServer.run() + # set siman python path before the session server launching to import scripts inside python console + if simanStudyName(args): + # MPV: use os.environ here because session server is launched in separated process and sys.path is missed in this case + os.environ["PYTHONPATH"] = "/tmp/SimanSalome/" + args['siman_study'] + "/" + \ + args['siman_scenario'] + "/" + args['siman_user'] + os.pathsep + os.environ["PYTHONPATH"]; + # Launch Session Server (to show splash ASAP) # @@ -608,12 +620,7 @@ def startSalome(args, modules_list, modules_root_dir): # if 'pyContainer' in args['standalone']: - myServer=ContainerPYServer(args) - myServer.run() - if sys.platform == "win32": - clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") - else: - clt.waitNSPID("/Containers/" + theComputer + "/FactoryServerPy",myServer.PID) + raise Exception('Python containers no longer supported') # # Wait until Session Server is registered in naming service @@ -670,6 +677,27 @@ def startSalome(args, modules_list, modules_root_dir): except ImportError: pass + # siman session paramenters and checkout processing + if simanStudyName(args): + print '**********************************************' + print "Siman study name= '" + simanStudyName(args) + "'" + import SALOMEDS + obj = clt.Resolve('myStudyManager') + myStudyManager = obj._narrow(SALOMEDS.StudyManager) + aNewStudy = myStudyManager.NewStudy(simanStudyName(args)) + aSimS = myStudyManager.GetSimanStudy() + aSimS._set_StudyId(args['siman_study']) + aSimS._set_ScenarioId(args['siman_scenario']) + aSimS._set_UserId(args['siman_user']) + aSimS.CheckOut(aNewStudy) + # if session server is enabled, activate the created study + if args["gui"]: + print "Activate the SIMAN study in the SALOME GUI" + obj = clt.Resolve('/Kernel/Session') + mySession = obj._narrow(SALOME.Session) + mySession.emitMessage("simanCheckoutDone " + simanStudyName(args)) + print '**********************************************' + return clt # ----------------------------------------------------------------------------- @@ -743,46 +771,20 @@ def useSalome(args, modules_list, modules_root_dir): pass pass - # run python scripts, passed via --execute option + # run python scripts, passed as command line arguments toimport = [] if args.has_key('pyscript'): if args.has_key('gui') and args.has_key('session_gui'): if not args['gui'] or not args['session_gui']: toimport = args['pyscript'] - for srcname in toimport : - if srcname == 'killall': - clt.showNS() - killAllPorts() - sys.exit(0) - else: - if os.path.isabs(srcname): - if os.path.exists(srcname): - execScript(srcname) - elif os.path.exists(srcname+".py"): - execScript(srcname+".py") - else: - print "Can't execute file %s" % srcname - pass - else: - found = False - for path in [os.getcwd()] + sys.path: - if os.path.exists(os.path.join(path,srcname)): - execScript(os.path.join(path,srcname)) - found = True - break - elif os.path.exists(os.path.join(path,srcname+".py")): - execScript(os.path.join(path,srcname+".py")) - found = True - break - pass - if not found: - print "Can't execute file %s" % srcname - pass - pass - pass - pass - pass + from salomeLauncherUtils import formatScriptsAndArgs + command = formatScriptsAndArgs(toimport) + if command: + proc = subprocess.Popen(command, shell=True) + res = proc.wait() + if res: sys.exit(1) # if there's an error when executing script, we should explicitly exit + return clt def execScript(script_path): @@ -828,6 +830,15 @@ def no_main(): def main(): """Salome launch as a main application""" + + # define folder to store omniorb config (initially in virtual application folder) + try: + from salomeLauncherUtils import setOmniOrbUserPath + setOmniOrbUserPath() + except Exception, e: + print e + sys.exit(1) + from salome_utils import getHostName print "runSalome running on %s" % getHostName() args, modules_list, modules_root_dir = setenv.get_config() @@ -843,7 +854,7 @@ def main(): pass if test: from searchFreePort import searchFreePort - searchFreePort(args, save_config) + searchFreePort(args, save_config, args.get('useport')) pass # -- #setenv.main() @@ -912,10 +923,9 @@ def foreGround(clt, args): killMyPort(port) pass return +# -# ----------------------------------------------------------------------------- - -if __name__ == "__main__": +def runSalome(): import user clt,args = main() # -- @@ -943,3 +953,10 @@ if __name__ == "__main__": pass # -- pass +# + +# ----------------------------------------------------------------------------- + +if __name__ == "__main__": + runSalome() +#