runSalome.py
runSession.py
runConsole.py
+ runRemote.py
runTests.py
${CMAKE_CURRENT_BINARY_DIR}/salomeContextUtils.py
salomeContext.py
salome_instance = SalomeInstance()
salome_instance.__run(args=instance_args, with_gui=with_gui)
- with open(port_log) as f:
- salome_instance.port = int(f.readline())
+ try:
+ with open(port_log) as f:
+ salome_instance.port = int(f.readline())
+ os.remove(port_log)
+ except:
+ pass
- os.remove(port_log)
return salome_instance
#
shutdown_servers_nam = "shutdown_servers"
foreground_nam = "foreground"
wake_up_session_nam = "wake_up_session"
+launcher_only_nam = "launcher_only"
+launcher_nam = "launcher"
# values in XML configuration file giving specific module parameters (<module_name> section)
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
# values of boolean type (must be '0' or '1').
# xml_parser.boolValue() is used for correct setting
-boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
+boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam, launcher_only_nam )
intKeys = ( interp_nam, )
+strKeys = ( launcher_nam )
# values of list type
listKeys = ( embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam )
self.opts[key] = self.boolValue( val ) # assign boolean value: 0 or 1
elif nam in intKeys:
self.opts[key] = self.intValue( val ) # assign integer value
+ elif nam in strKeys:
+ self.opts[key] = val # assign value
elif nam in listKeys:
self.opts[key] = [ self.strValue( a ) for a in re.split( "[:;,]", val ) ] # assign list value: []
else:
dest="print_port",
help=help_str)
+ # launch only omniNames and Launcher server
+ help_str = "launch only omniNames and Launcher server"
+ pars.add_argument("--launcher_only",
+ action="store_true",
+ dest="launcher_only",
+ help=help_str)
+
+ # machine and port where is the Launcher
+ help_str = "machine and port where is the Launcher. Usage: "
+ help_str += "--launcher=machine:port"
+ pars.add_argument("--launcher",
+ metavar="<=machine:port>",
+ type=str,
+ dest="launcher",
+ help=help_str)
+
# Do not relink ${HOME}/.omniORB_last.cfg
help_str = "Do not save current configuration ${HOME}/.omniORB_last.cfg"
pars.add_argument("--nosave-config",
# - Command line options have the highest priority and replace options
# specified in configuration file(s)
###
-
global args
config_var = appname+'Config'
args[shutdown_servers_nam] = cmd_opts.shutdown_servers
pass
+ # Launcher only
+ if cmd_opts.launcher_only is not None:
+ args[launcher_only_nam] = cmd_opts.launcher_only
+
+ # machine and port where is the Launcher
+ if cmd_opts.launcher is not None:
+ args[launcher_nam] = cmd_opts.launcher
+
# Foreground
if cmd_opts.foreground is None:
args[foreground_nam] = 1
def __init__(self,args=None):
# Initialise the ORB
+
+ if args is not None and 'launcher' in args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ sys.argv.append('-ORBInitRef')
+ sys.argv.append("NameService=corbaname::" + machine + ":" + port)
+ print("Connect to naming service on machine: "+machine+" port: "+port)
self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
# Initialise the Naming Service
--- /dev/null
+# Copyright (C) 2007-2018 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
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+from optparse import OptionParser
+import subprocess
+from salome_utils import getUserName
+from salomeContextUtils import getShortAndExtraArgs
+
+# Use to display newlines (\n) in epilog
+class MyParser(OptionParser):
+ def format_epilog(self, formatter):
+ return self.epilog
+#
+#
+# --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
+def _writeConfigFile(port, host):
+ path = os.environ['OMNIORB_USER_PATH']
+ kwargs = {'with_username' : getUserName()}
+
+ from ORBConfigFile import writeORBConfigFile
+ [ filename, msgSize ] = writeORBConfigFile(path, host, port, kwargs)
+
+ os.environ['OMNIORB_CONFIG'] = filename
+#
+
+def runRemote(args):
+ if args is None:
+ args = []
+ usage = "Usage: salome runremote [options] -- command"
+ epilog = """\n
+Execute command in SALOME environment from a remote call, ssh or rsh.
+salome runremote is used notably to launch containers from a distant salome session.
+
+For example:
+ salome remote -m xxx.cea.fr -p 2810 -- ls /tmp >/dev/null 2>&1
+ -> execute the command ls /tmp >/dev/null 2>&1
+
+ salome remote -m xxx.cea.fr -p 2810 -- SALOME_Container Cont_S
+ -ORBInitRef NameService=IOR:01...
+ -> starts a Salome container called Cont_S connected to port 2810
+ of xxx.cea.fr
+"""
+ parser = MyParser(usage=usage, epilog=epilog)
+ parser.add_option("-p", "--port", metavar="<port>", default="2810",
+ action="store", type="string", dest="port",
+ help="The port to connect to."
+ )
+ parser.add_option("-m", "--machine", metavar="<machine>",
+ action="store", type="string", dest="host",
+ default="localhost",
+ help="The machine where salome was launched."
+ )
+ parser.add_option('-d', '--directory', dest="directory",
+ metavar="<directory>", default=None,
+ help="The directory where to execute the command."
+ )
+
+ # separate runRemote args from the command to run (given after --)
+ short_args, extra_args = getShortAndExtraArgs(args)
+ try:
+ (options, args) = parser.parse_args(short_args)
+ except Exception as e:
+ print(e)
+ print(usage)
+ print(epilog)
+ return
+
+ port = options.port
+ host = options.host
+ directory = options.directory
+ command=extra_args[1:]
+
+ _writeConfigFile(port, host)
+ os.environ['NSPORT'] = port
+ os.environ['NSHOST'] = host
+ print("[ Remote Command ] ", " ".join(command))
+ cmd = subprocess.Popen(command, cwd=directory)
+ cmd.wait()
+ return
+#
+
def __init__(self,args):
self.args=args
self.initArgs()
- self.SCMD1=['SALOME_ModuleCatalog_Server','-common']
+ self.SCMD1=['SALOME_ModuleCatalog_Server']
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.SCMD1+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.SCMD1+=["NameService=corbaname::" + machine + ":" + port]
+ self.SCMD1+=['-common']
self.SCMD2=[]
home_dir=os.getenv('HOME')
if home_dir is not None:
self.args=args
self.initArgs()
self.CMD=['SALOMEDS_Server']
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.CMD+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.CMD+=["NameService=corbaname::" + machine + ":" + port]
# ---
self.args=args
self.initArgs()
self.CMD=['SALOME_ConnectionManagerServer']
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.CMD+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.CMD+=["NameService=corbaname::" + machine + ":" + port]
+
# ---
self.args=args
self.initArgs()
self.CMD=['SALOME_Registry_Server', '--salome_session','theSession']
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.CMD+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.CMD+=["NameService=corbaname::" + machine + ":" + port]
# ---
def __init__(self,args,with_gui=False):
self.args=args
self.initArgs()
- self.CMD=['SALOME_Container','FactoryServer']
+ self.CMD=['SALOME_Container']
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.CMD+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.CMD+=["NameService=corbaname::" + machine + ":" + port]
+ self.CMD+=['FactoryServer']
if not with_gui and self.args["valgrind_session"]:
l = ["valgrind"]
val = os.getenv("VALGRIND_OPTIONS")
self.initArgs()
self.SCMD1=['SALOME_Session_Server']
self.SCMD2=[]
+ if 'launcher' in self.args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ self.SCMD1+=['-ORBInitRef']
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ self.SCMD1+=["NameService=corbaname::" + machine + ":" + port]
if 'registry' in self.args['embedded']:
self.SCMD1+=['--with','Registry',
'(','--salome_session','theSession',')']
# Launch Session Server (to show splash ASAP)
#
- if args["gui"]:
+ if args["gui"] and not args['launcher_only']:
mySessionServ = SessionServer(args,args['modules'],modules_root_dir)
mySessionServ.setpath(modules_list,modules_root_dir)
mySessionServ.run()
# Launch LauncherServer
#
- myCmServer = LauncherServer(args)
- myCmServer.setpath(modules_list,modules_root_dir)
- myCmServer.run()
+ if not 'launcher' in args:
+ myCmServer = LauncherServer(args)
+ myCmServer.setpath(modules_list,modules_root_dir)
+ myCmServer.run()
#
# Launch ConnectionManagerServer
#
- myConnectionServer = ConnectionManagerServer(args)
- myConnectionServer.run()
-
+ if not args['launcher_only']:
+ myConnectionServer = ConnectionManagerServer(args)
+ myConnectionServer.run()
from Utils_Identity import getShortHostName
# Wait until Session Server is registered in naming service
#
- if args["gui"]:
+ if args["gui"] and not args['launcher_only']:
##----------------
import Engines
import SALOME
if args['wake_up_session']:
test = False
pass
- if test:
+ if test and not 'launcher' in args:
from searchFreePort import searchFreePort
searchFreePort(args, save_config, args.get('useport'))
pass
help="[Remote mode] The user on the computer to connect to."
)
+ parser.add_option('-l', '--launcher', dest="launcher", default=None,
+ help="[Remote mode] The machine and the port to connect to."
+ )
+
short_args, extra_args = getShortAndExtraArgs(args)
try:
(options, args) = parser.parse_args(short_args)
port = options.port
host = options.host
+ launcher = options.launcher
+ if launcher is not None:
+ pos = launcher.find(":")
+ if pos != -1:
+ host = launcher[0:pos]
+ port = launcher[pos+1:]
# :GLITCH: this code defines specific environment variables (OMNIORB_CONFIG, NSPORT,
# NSHOST) which are later used by other modules. Working, but not really "safe"...
# determine running mode, that is either 'local' or 'remote'
here = getShortHostName()
mode = "local"
- if host != here and host != "localhost" and host != "no_host":
+ if host != here and host != "localhost" and host != "no_host" and launcher is None:
mode="remote"
pass
params = SessionParameters(mode, port, host, options.user, options.directory)
User works in a Shell terminal. SALOME environment is set but
application is not started.
connect Connect a Python console to the active SALOME instance.
+ remote run command in SALOME environment from remote call, ssh or rsh.
kill <port(s)> Terminate SALOME instances running on given ports for current user.
Port numbers must be separated by blank characters.
killall Terminate *all* SALOME running instances for current user.
'start' : '_runAppli',
'context' : '_setContext',
'shell' : '_runSession',
+ 'remote' : '_runRemote',
'connect' : '_runConsole',
'kill' : '_kill',
'killall' : '_killAll',
return runSession.runSession(params, args)
#
+ def _runRemote(self, args=None):
+ if args is None:
+ args = []
+# complete salome environment
+ sys.argv = ['runRemote']
+ import setenv
+ setenv.main(True)
+
+ import runRemote
+ return runRemote.runRemote(args)
+ #
+
def _runConsole(self, args=None):
if args is None:
args = []
# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
# an exception is raised if check fails. It allows users for choosing a specific folder.
# Else the function sets OMNIORB_USER_PATH this way:
-# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
-# The function does not check USERS folder existence or write access. This folder
-# must exist ; this is the case if SALOME virtual application has been created using
+# - If APPLI environment variable is set, and if ${APPLI}/USERS points at an existing
+# folder with write access, then OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+# This is the case if SALOME virtual application has been created using
# appli_gen.py script.
# - Else OMNIORB_USER_PATH is set to user home directory.
def setOmniOrbUserPath():
#defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
defaultOmniorbUserPath = homePath
if os.getenv("APPLI"):
- defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ appli_users_path=os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ if os.access(appli_users_path, os.W_OK):
+ defaultOmniorbUserPath = appli_users_path
pass
os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
#
import os
from salome_utils import getLogDir, generateFileName, makeTmpDir, getPortNumber
+ if 'launcher' in args:
+ pos = args['launcher'].find(":")
+ if pos != -1:
+ machine = args['launcher'][0:pos]
+ port = args['launcher'][pos+1:]
+ os.environ["NSPORT"] = port
+
# create temporary directory for environment files needed by modules from the list
port = getPortNumber(False)
if port:
// Only if an application directory is set
if(hostname != Kernel_Utils::GetHostname() && _isAppliSalomeDefined)
{
- // Preparing remote command
- std::string command = "";
+
const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_selected));
- command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
- if (resInfo.AppliPath != "")
- command += resInfo.AppliPath;
- else
- {
- ASSERT(GetenvThreadSafe("APPLI"));
- command += GetenvThreadSafeAsString("APPLI");
- }
- command += "/runRemote.sh ";
- ASSERT(GetenvThreadSafe("NSHOST"));
- command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
- command += " ";
- ASSERT(GetenvThreadSafe("NSPORT"));
- command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
- command += " \"ls /tmp >/dev/null 2>&1\"";
+ std::string command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName,
+ resInfo.UserName, resInfo.AppliPath);
// Launch remote command
+ command += " \"ls /tmp >/dev/null 2>&1\"";
int status = SystemThreadSafe(command.c_str());
if (status != 0)
{
nbproc = params.nb_proc;
}
- // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir
- // SALOME_Container containerName &"
- command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
-
- if (resInfo.AppliPath != "")
- command += resInfo.AppliPath; // path relative to user@machine $HOME
- else
- {
- ASSERT(GetenvThreadSafe("APPLI"));
- command += GetenvThreadSafeAsString("APPLI"); // path relative to user@machine $HOME
- }
-
- command += "/runRemote.sh ";
-
- ASSERT(GetenvThreadSafe("NSHOST"));
- command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
-
- command += " ";
- ASSERT(GetenvThreadSafe("NSPORT"));
- command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
-
std::string wdir = params.workingdir.in();
- if(wdir != "")
- {
- command += " WORKINGDIR ";
- command += " '";
- if(wdir == "$TEMPDIR")
- wdir="\\$TEMPDIR";
- command += wdir; // requested working directory
- command += "'";
- }
+
+ // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
+ // SALOME_Container containerName -ORBInitRef NameService=IOR:01000..."
+ // or
+ // "ssh -l user machine distantLauncher remote -p hostNS -m portNS -d dir
+ // -- SALOME_Container contName -ORBInitRef NameService=IOR:01000..."
+ command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName,
+ resInfo.UserName, resInfo.AppliPath,
+ wdir);
if(params.isMPI)
{
{
if (_isAppliSalomeDefined)
{
-
- if (resInfo.Protocol == rsh)
- command = "rsh ";
- else if (resInfo.Protocol == ssh)
- command = "ssh ";
- else if (resInfo.Protocol == srun)
- command = "srun -n 1 -N 1 --share --mem-per-cpu=0 --nodelist=";
- else
- throw SALOME_Exception("Unknown protocol");
-
- if (resInfo.UserName != "")
- {
- command += "-l ";
- command += resInfo.UserName;
- command += " ";
- }
-
- command += resInfo.HostName;
- command += " ";
-
- if (resInfo.AppliPath != "")
- command += resInfo.AppliPath; // path relative to user@machine $HOME
- else
- {
- ASSERT(GetenvThreadSafe("APPLI"));
- command += GetenvThreadSafeAsString("APPLI"); // path relative to user@machine $HOME
- }
-
- command += "/runRemote.sh ";
-
- ASSERT(GetenvThreadSafe("NSHOST"));
- command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
-
- command += " ";
- ASSERT(GetenvThreadSafe("NSPORT"));
- command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
-
+ command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName,
+ resInfo.UserName, resInfo.AppliPath);
command += " mpirun -np 1 hostname -s > " + tmpFile;
}
else
std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocolType protocol,
const std::string & hostname,
- const std::string & username)
+ const std::string & username,
+ const std::string & applipath,
+ const std::string & workdir)
{
std::ostringstream command;
switch (protocol)
throw SALOME_Exception("Unknown protocol");
}
+ std::string remoteapplipath;
+ if (applipath=="")
+ remoteapplipath = GetenvThreadSafeAsString("APPLI");
+ else
+ remoteapplipath = applipath;
+
+ ASSERT(GetenvThreadSafe("NSHOST"));
+ ASSERT(GetenvThreadSafe("NSPORT"));
+
+ // $APPLI points either to an application directory, or to a salome launcher file
+ // we prepare the remote command according to the case
+ struct stat statbuf;
+ if (stat(GetenvThreadSafe("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
+ {
+ // if $APPLI is a regular file, we asume it's a salome Launcher
+ // generate a command with a salome launcher
+ command << remoteapplipath
+ << " remote"
+ << " -m "
+ << GetenvThreadSafeAsString("NSHOST") // hostname of CORBA name server
+ << " -p "
+ << GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
+ if (workdir != "")
+ command << "-d " << workdir;
+ command << " -- " ;
+ }
+ else // we assume it's a salome application directory
+ {
+ // generate a command with runRemote.sh
+ command << remoteapplipath;
+ command << "/runRemote.sh ";
+ command << GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
+ command << " ";
+ command << GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
+ if(workdir != "")
+ {
+ command << " WORKINGDIR ";
+ command << " '";
+ if(workdir == "$TEMPDIR")
+ command << "\\$TEMPDIR";
+ else
+ command << workdir; // requested working directory
+ command << "'";
+ }
+ }
+
return command.str();
}
std::string machinesFile(const int nbproc);
- static std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, const std::string & hostname, const std::string & username);
+ static std::string getCommandToRunRemoteProcess(AccessProtocolType protocol,
+ const std::string & hostname,
+ const std::string & username,
+ const std::string & applipath,
+ const std::string & workdir="");
Engines::Container_ptr
LaunchContainer(const Engines::ContainerParameters& params,
// Module : KERNEL
//
#include "ConnectionManager_i.hxx"
-#include "SALOME_NamingService.hxx"
#ifdef WIN32
# include <process.h>
# include <unistd.h>
#endif
+const char * ConnectionManager_i::_ConnectionManagerNameInNS = "/ConnectionManager";
+
ConnectionManager_i::ConnectionManager_i(CORBA::ORB_ptr orb) {
_orb = CORBA::ORB::_duplicate(orb) ;
- SALOME_NamingService * ns = new SALOME_NamingService(orb);
- const char * ConnectionManagerNameInNS = "/ConnectionManager";
+ _NS = new SALOME_NamingService(orb);
CORBA::Object_var obref = _this();
_remove_ref();
- ns->Register(obref, ConnectionManagerNameInNS);
- delete ns;
+ _NS->Register(obref, _ConnectionManagerNameInNS);
current_id = 0;
pthread_mutex_init(&mutex, NULL);
}
-ConnectionManager_i::~ConnectionManager_i() {}
+ConnectionManager_i::~ConnectionManager_i()
+{
+ delete _NS;
+}
Engines::ConnectionManager::connectionId
ConnectionManager_i::connect(Engines::DSC_ptr uses_component,
void
ConnectionManager_i::ShutdownWithExit()
{
+ _NS->Destroy_Name(_ConnectionManagerNameInNS);
ids_it = ids.begin();
while(ids_it != ids.end())
{
#define _CONNECTION_MANAGER_I_HXX_
#include "DSC_Basic.hxx"
+#include "SALOME_NamingService.hxx"
#include <iostream>
#include <map>
*/
CORBA::Long getPID();
+ static const char *_ConnectionManagerNameInNS;
+
private :
struct connection_infos {
pthread_mutex_t mutex;
protected:
CORBA::ORB_var _orb;
+ SALOME_NamingService * _NS;
};
#endif
*/
//=============================================================================
-void SALOME_LifeCycleCORBA::shutdownServers()
+void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
{
// get each Container from NamingService => shutdown it
// (the order is inverse to the order of servers initialization)
SALOMEDS::Study_var study = SALOMEDS::Study::_narrow(objSDS) ;
if ( !CORBA::is_nil(study) && ( pid != study->getPID() ) )
study->Shutdown();
+ _NS->Destroy_Name("/Study");
}
catch(const CORBA::Exception& e)
{
SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
catalog->shutdown();
+ _NS->Destroy_Name("/Kernel/ModulCatalog");
}
catch(const CORBA::Exception& e)
{
// 5) SalomeLauncher
try
{
- CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
- Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
- if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
- launcher->Shutdown();
+ if(shutdownLauncher){
+ CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
+ Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
+ if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
+ launcher->Shutdown();
+ }
}
catch(const CORBA::Exception& e)
{
Registry::Components_var registry = Registry::Components::_narrow(objR);
if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
registry->Shutdown();
+ _NS->Destroy_Name("/Registry");
}
catch(const CORBA::Exception& e)
{
CORBA::ORB_ptr orb();
void copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest);
- void shutdownServers();
+ void shutdownServers(bool shutdownLauncher=true);
static void killOmniNames();
protected:
self._obj = None
return self._obj
+ #-------------------------------------------------------------------------
+
+ def Resolve_Dir(self, Path):
+ """ ns.Resolve_Dir(pathname) -> dir
+
+ find a CORBA object (ior) by its pathname
+ """
+ #MESSAGE ( "SALOME_NamingServicePy_i::Resolve" )
+ path_list = list(Path)
+ if path_list[0]=='/':
+ self._current_context = self._root_context
+ #delete first '/' before split
+ Path=Path[1:]
+
+ result_resolve_path = Path.split('/')
+ _context_name=[]
+ for i in range(len(result_resolve_path)-1):
+ _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir"))
+ _context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"dir"))
+ print(_context_name)
+ return None
+ try:
+ self._obj = self._current_context.resolve(_context_name)
+ except CosNaming.NamingContext.NotFound as ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.NotFound" )
+ self._obj = None
+ except CosNaming.NamingContext.InvalidName as ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.InvalidName" )
+ self._obj = None
+ except CosNaming.NamingContext.CannotProceed as ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" )
+ self._obj = None
+ except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
+ MESSAGE ( "Resolve : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" )
+ self._obj = None
+ return self._obj
+
#-------------------------------------------------------------------------
default_file += "/";
default_file += getenv("APPLI");
default_file += "/CatalogResources.xml";
- _path_resources.push_back(default_file);
- }
- else
- {
- if(!getenv("KERNEL_ROOT_DIR"))
- throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!! -> cannot load a CatalogResources.xml");
- default_file = getenv("KERNEL_ROOT_DIR");
- default_file += "/share/salome/resources/kernel/CatalogResources.xml";
- _path_resources.push_back(default_file);
+ std::ifstream ifile(default_file.c_str(), std::ifstream::in );
+ if (ifile) {
+ // The file exists, and is open for input
+ _path_resources.push_back(default_file);
+ default_catalog_resource=false;
+ }
}
}
+ if (default_catalog_resource)
+ {
+ std::string default_file("");
+ if(!getenv("KERNEL_ROOT_DIR"))
+ throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!! -> cannot load a CatalogResources.xml");
+ default_file = getenv("KERNEL_ROOT_DIR");
+ default_file += "/share/salome/resources/kernel/CatalogResources.xml";
+ _path_resources.push_back(default_file);
+ }
ParseXmlFiles();
RES_MESSAGE("ResourcesManager_cpp constructor end");
#endif
orb->run();
MESSAGE( "end of SALOME_DS server" );
+ NS->Destroy_Name("/Study");
orb->destroy();
}
catch(CORBA::SystemException&)