runNS.sh \
launchConfigureParser.py \
salome.launch \
+envSalome.py \
+salomeConsole.py \
showNS.py
# copy header files in common directory
--- /dev/null
+#!/usr/bin/env python
+import os
+import sys
+
+kernel_root=os.getenv("KERNEL_ROOT_DIR")
+sys.path[:0]=[kernel_root+"/bin/salome"]
+
+import runSalome
+
+argv=sys.argv[1:]
+sys.argv=[]
+
+args, modules_list, modules_root_dir = runSalome.get_config()
+runSalome.set_env(args, modules_list, modules_root_dir)
+
+os.execvp(argv[0],argv)
# -----------------------------------------------------------------------------
-### searching for launch configuration file : $HOME/.$(application_name)/$(application_name).launch
-
-appname = None
-dirname = None
-filename = None
-for bindir in glob.glob(os.environ["KERNEL_ROOT_DIR"]+"/bin/*"):
- appname = string.split(bindir, "/").pop()
- print 'Application name: "'+appname+'"'
- # find version number
- versnb = ""
- try:
- file = open(os.environ["KERNEL_ROOT_DIR"]+"/bin/"+appname+"/VERSION", "r")
- s = file.read()
- l = string.split(s, ":")
- vl = string.split(l[1], " ")
- i = 0
- while len(versnb) == 0:
- versnb = vl[i]
- i += 1
- pass
- versnb = string.split(versnb, "\n")[0]
- print "Version ",versnb
- except:
- pass
- # end find version number
- dirname = os.environ["HOME"]+"/."+appname+"_"+versnb
- filename = dirname+"/"+appname+".launch"
- if not os.path.exists(filename) and \
- not os.path.exists(os.environ["KERNEL_ROOT_DIR"]+"/bin/"+appname+"/"+appname+".launch"):
- filename = None
- else:
- break
- pass
-if not appname:
- print "Can not find application name"
- if not os.have_key("KERNEL_ROOT_DIR"):
- print "KERNEL_ROOT_DIR environment variable must be set"
- pass
- sys.exit(1);
-elif not filename or not os.path.exists(filename):
- filename = dirname+"/"+appname+".launch"
- #filename = os.environ["HOME"]+"/."+appname+"/"+appname+".launch"
- print "Launch configuration file does not exist. Create default:",filename
- os.system("mkdir -p "+dirname)
- #os.system("mkdir -p "+os.environ["HOME"]+"/."+appname)
- os.system("cp -f "+os.environ["KERNEL_ROOT_DIR"]+"/bin/"+appname+"/"+appname+".launch "+filename)
- pass
+### searching for launch configuration file : $HOME/applipath()/salome.launch
+
+appname="salome"
+import Utils_Identity
+versnb=Utils_Identity.version()
+dirname = os.path.join(os.environ["HOME"],Utils_Identity.getapplipath())
+filename=os.path.join(dirname,"salome.launch")
+
+if not os.path.exists(filename):
+ print "Launch configuration file does not exist. Create default:",filename
+ os.system("mkdir -p "+dirname)
+ os.system("cp -f "+os.environ["KERNEL_ROOT_DIR"]+"/bin/salome/salome.launch "+filename)
### get options from launch configuration file
print """USAGE: runSalome.py [options]
[command line options] :
--help or -h : print this help
- --gui or -g : lancement du GUI
+ --gui or -g : launching with GUI
--terminal -t : launching without gui (to deny --gui)
- --logger or -l : redirection des messages via CORBA
- --file=filename or -l=filename: redirection des messages dans un fichier
- --xterm or -x : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre
- --modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue
+ --logger or -l : redirect messages in a CORBA collector
+ --file=filename or -f=filename: redirect messages in a log file
+ --xterm or -x : execute servers in xterm console (messages appear in xterm windows)
+ --modules=module1,module2,... : salome module list (modulen is the name of Salome module to load)
or -m=module1,module2,...
--embedded=registry,study,moduleCatalog,cppContainer
or -e=registry,study,moduleCatalog,cppContainer
- : serveurs CORBA embarqués (par defaut: registry,study,moduleCatalog,cppContainer)
- : (logger,pyContainer,supervContainer ne peuvent pas être embarqués
+ : embedded CORBA servers (default: registry,study,moduleCatalog,cppContainer)
+ : (logger,pyContainer,supervContainer can't be embedded
--standalone=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer
or -s=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer
- : executables serveurs CORBA indépendants (par défaut: pyContainer,supervContainer)
- --containers=cpp,python,superv: (obsolete) lancement des containers cpp, python et de supervision
- or -c=cpp,python,superv : = on prend les defauts de -e et -s
+ : standalone CORBA servers (default: pyContainer,supervContainer)
+ --containers=cpp,python,superv: (obsolete) launching of containers cpp, python and supervision
+ or -c=cpp,python,superv : = get default from -e and -s
--portkill or -p : kill the salome with current port
--killall or -k : kill salome
- La variable d'environnement <modulen>_ROOT_DIR doit etre préalablement
- positionnée (modulen doit etre en majuscule).
- KERNEL_ROOT_DIR est obligatoire.
+ For each Salome module, the environment variable <modulen>_ROOT_DIR must be set.
+ The module name (<modulen>) must be uppercase.
+ KERNEL_ROOT_DIR is mandatory.
"""
sys.exit(1)
pass
self.modules_root_dir=modules_root_dir
myLogName = os.environ["LOGNAME"]
self.CMD=['notifd','-c',
- self.modules_root_dir["KERNEL"]
- +'/share/salome/resources/channel.cfg',
+ self.modules_root_dir["KERNEL"] +'/share/salome/resources/channel.cfg',
'-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior',
- '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior']
+ '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior',
+ '-DReportLogFile=/tmp/'+myLogName+'_notifd.report',
+ '-DDebugLogFile=/tmp/'+myLogName+'_notifd.debug',
+ ]
#
# -----------------------------------------------------------------------------
try:
clt = startSalome(args, modules_list, modules_root_dir)
except:
+ import traceback
+ traceback.print_exc()
print
print
print "--- erreur au lancement Salome ---"
# -----------------------------------------------------------------------------
if __name__ == "__main__":
+ import user
clt,args = main()
--- /dev/null
+#!/usr/bin/env python
+
+import os
+import sys
+#-------------------------------
+# Python completion and others if you want
+# You should have set PYTHONSTARTUP env variable
+# or import user should try to import $HOME/.pythonrc.py
+#-------------------------------
+import user
+
+#-------------------------------
+# Get major CORBA objects
+#-------------------------------
+import CORBA
+import CosNaming
+# There are cyclic dependencies between Engines, SALOME and SALOMEDS.
+# import first Engines, then SALOME and then SALOMEDS
+# Or use reload(Engines) to be safe.
+import Engines
+import SALOME
+import SALOMEDS
+import SALOME_ModuleCatalog
+reload(Engines)
+reload(SALOME)
+reload(SALOMEDS)
+
+import LifeCycleCORBA
+import orbmodule
+from runSalome import *
+
+import Utils_Identity
+files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),".omni*.cfg"))
+
+filename=""
+if len(files)==1:
+ filename=files[0]
+else:
+ print "You have %d sessions running" % len(files)
+ for f in files:
+ print "Session:",f
+ rep= raw_input("Do you want to connect to this session [y|n]")
+ if rep == "y":
+ filename=f
+ break
+
+if filename != "":
+ os.environ['OMNIORB_CONFIG']=filename
+else:
+ rep= raw_input("Do you want to try a local session on port 2810 ? [y|n]")
+ if rep == "y":
+ # Try a local session running on port 2810
+ sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810']
+ else:
+ sys.exit(1)
+
+print sys.argv
+
+#direct adress from clt.orb.object_to_string(clt.rootContext)
+#sys.argv=sys.argv+['-ORBInitRef','NameService=IOR:010000000100000000000000010000000000000023000000010100000a0000006c6f63616c686f737400fa0a0b0000004e616d6553657276696365']
+
+class client(orbmodule.client):
+ def initNS(self):
+ # Obtain a reference to the root naming context
+ obj = self.orb.resolve_initial_references("NameService")
+ try:
+ self.rootContext = obj._narrow(CosNaming.NamingContext)
+ return
+ except CORBA.COMM_FAILURE:
+ print "It's not a valid naming service"
+ self.rootContext = None
+ raise
+
+clt=client()
+print "Naming Service address: ",clt.orb.object_to_string(clt.rootContext)
+
+clt.showNS()
+
+session=clt.waitNS("/Kernel/Session")
+catalog=clt.waitNS("/Kernel/ModulCatalog")
+studyMgr=clt.waitNS("/myStudyManager")
+lcc = LifeCycleCORBA.LifeCycleCORBA(clt.orb)
+
+#c=lcc.FindOrStartContainer("","totoPy")
+#print c
*/
Component load_impl(in string nameToRegister, in string componentName);
+/*!
+ Loads into the container a new component, registers it and starts it's CORBA servant.
+ \param nameToRegister Name used to register in Naming Service, the component instance
+ \param componentName Name of the %component
+ \return a new instance of the component or the registered component if already registered or Nil if not possible
+*/
+ Component instance(in string nameToRegister, in string componentName);
+
/*!
Stops the component servant, and deletes all related objects
\param component_i Component to be removed
<constraint>hostname = muna</constraint>
</component>
+ <component>
+ <component-name>SalomeTestComponent</component-name>
+ <component-username>SalomeTestComponent</component-username>
+ <component-type>Other</component-type>
+ <component-author>NRI</component-author>
+ <component-version>2.1.0</component-version>
+ <component-comment>GUI Neutral Context</component-comment>
+ <component-multistudy>1</component-multistudy>
+ <constraint>'linux' ~ OS</constraint>
+ </component>
+ <component>
+ <component-name>SALOME_TestComponentPy</component-name>
+ <component-username>SALOME_TestComponentPy</component-username>
+ <component-type>Other</component-type>
+ <component-author>NRI</component-author>
+ <component-version>2.1.0</component-version>
+ <component-comment>GUI Neutral Context</component-comment>
+ <component-multistudy>1</component-multistudy>
+ <constraint>'linux' ~ OS</constraint>
+ </component>
</component-list>
</begin-catalog>
version=`sip -V`
case "$version" in
3.2*)
- sip_vers=old ;;
+ SIP_VERS=old ;;
3.3*)
- sip_vers=old ;;
+ SIP_VERS=old ;;
3.4*)
- sip_vers=new ;;
+ SIP_VERS=new ;;
3.5*)
- sip_vers=new ;;
+ SIP_VERS=new ;;
3.6*)
- sip_vers=new ;;
+ SIP_VERS=new ;;
3.7*)
- sip_vers=new ;;
+ SIP_VERS=new ;;
3.8*)
- sip_vers=new ;;
+ SIP_VERS=new ;;
3.9*)
- sip_vers=new ;;
- *)
- sip_vers=no ;;
+ SIP_VERS=new ;;
+ 3.10*)
+ SIP_VERS=new2 ;;
+ *)
+ AC_MSG_RESULT(sip version $version not supported)
+ SIP_VERS=no ;;
esac
sip_ok=no
- if test "x$sip_vers" = "xold"
+ if test "x$SIP_VERS" = "xold"
then
+ dnl old install : includes and libs are in python install or in SIPDIR
+ AC_MSG_RESULT(old install detected)
sip_ok=yes
SIP_ROOT="$SIPDIR"
SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}"
SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -L${SIPDIR} -lsip"
fi
- if test "x$sip_vers" = "xnew"
+ if test "x$SIP_VERS" = "xnew"
then
sip_ok=yes
if test -d ${SIPDIR}/include/python${PYTHON_VERSION} ; then
+ AC_MSG_RESULT(new install with include dir detected)
+ dnl new install with include dir : includes and libs are in python install or in SIPDIR/include
SIP_ROOT="$SIPDIR"
SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}/include/python${PYTHON_VERSION}"
SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages -lsip"
else
+ dnl new install without include dir : includes and libs are in SIPDIR
+ AC_MSG_RESULT(new install without include dir detected)
sip_ok=yes
SIP_ROOT="$SIPDIR"
SIP_INCLUDES="-I${SIPDIR}"
fi
fi
+ if test "x$SIP_VERS" = "xnew2"
+ then
+ dnl new2 install : includes and libs are in python install
+ AC_MSG_RESULT(new2 install detected)
+ sip_ok=yes
+ AC_CHECK_FILE($PYTHON_PREFIX/include/python$PYTHON_VERSION/sip.h,sip_ok=$sip_ok,sip_ok=no)
+ SIP_INCLUDES="${PYTHON_INCLUDES}"
+ AC_CHECK_FILE($PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages/libsip.so,sip_ok=$sip_ok,sip_ok=no)
+ SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip"
+ fi
fi
AC_SUBST(SIP)
AC_SUBST(SIP_INCLUDES)
AC_SUBST(SIP_LIBS)
+AC_SUBST(SIP_VERS)
AC_MSG_RESULT(for sip: $sip_ok)
SIP = @SIP@
SIP_INCLUDES = @SIP_INCLUDES@
SIP_LIBS = @SIP_LIBS@
+SIP_VERS = @SIP_VERS@
# PYQT
PYQT_SIPS = @PYQT_SIPS@
return ret;
}
+
+/*
+ * Create one instance of componentName component and register it
+ * as nameToRegister in naming service
+ */
+Engines::Component_ptr Engines_Container_i::instance( const char* nameToRegister,
+ const char* componentName ) {
+
+ _numInstanceMutex.lock() ; // lock on the instance number
+ BEGIN_OF( "Container_i::instance " << componentName ) ;
+
+ string _nameToRegister = nameToRegister;
+ string component_registerName = _containerName + "/" + _nameToRegister;
+
+ Engines::Component_var iobject = Engines::Component::_nil() ;
+
+ try {
+ CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ;
+ if (! CORBA::is_nil( obj ) ) {
+ MESSAGE( "Container_i::instance " << component_registerName.c_str() << " already registered" ) ;
+ iobject = Engines::Component::_narrow( obj ) ;
+ }
+ else{
+ string _compo_name = componentName;
+ string _impl_name = "lib" + _compo_name + "Engine.so";
+ SCRUTE(_impl_name);
+
+ void* handle;
+ handle = dlopen( _impl_name.c_str() , RTLD_LAZY ) ;
+
+ if ( handle ) {
+ string factory_name = _compo_name + "Engine_factory";
+ SCRUTE(factory_name) ;
+
+ typedef PortableServer::ObjectId * (*FACTORY_FUNCTION)
+ (CORBA::ORB_ptr,
+ PortableServer::POA_ptr,
+ PortableServer::ObjectId *,
+ const char *,
+ const char *) ;
+ FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str());
+
+ char *error ;
+ if ( (error = dlerror() ) == NULL) {
+ // Instanciate required CORBA object
+ _numInstance++ ;
+ char _aNumI[12];
+ sprintf( _aNumI , "%d" , _numInstance ) ;
+ string instanceName = _compo_name + "_inst_" + _aNumI ;
+ SCRUTE(instanceName);
+
+ PortableServer::ObjectId * id ;
+ id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str() ,
+ _nameToRegister.c_str() ) ;
+ // get reference from id
+ obj = _poa->id_to_reference(*id);
+ iobject = Engines::Component::_narrow( obj ) ;
+
+ // register the engine under the name containerName.dir/nameToRegister.object
+ _NS->Register( iobject , component_registerName.c_str() ) ;
+ MESSAGE( "Container_i::instance " << component_registerName.c_str() << " registered" ) ;
+ handle_map[instanceName] = handle;
+ }
+ else{
+ INFOS("Can't resolve symbol: " + factory_name);
+ SCRUTE(error);
+ }
+ }
+ else{
+ INFOS("Can't load shared library : " << _impl_name);
+ INFOS("error dlopen: " << dlerror());
+ }
+ }
+ }
+ catch (...) {
+ INFOS( "Container_i::instance exception caught" ) ;
+ }
+ END_OF("Container_i::instance");
+ _numInstanceMutex.unlock() ;
+ return Engines::Component::_duplicate(iobject);
+}
+
# (if not, incomplete import done by SALOME module: no load of SALOMEDS_attributes)
import SALOMEDS
import Engines, Engines__POA
+reload(Engines)
+reload(Engines__POA)
from SALOME_NamingServicePy import *
from SALOME_ComponentPy import *
#-------------------------------------------------------------------------
+ def instance(self, nameToRegister, componentName):
+ MESSAGE( "SALOME_ContainerPy_i::instance " + str(nameToRegister) + ' ' + str(componentName) )
+ self._numInstance = self._numInstance +1
+ instanceName = nameToRegister + "_inst_" + `self._numInstance`
+
+ component=__import__(componentName)
+ factory=getattr(component,componentName)
+ comp_i=factory(self._orb, self._poa, self._this(), self._containerName,
+ instanceName, nameToRegister)
+
+ MESSAGE( "SALOME_ContainerPy_i::instance : component created")
+ comp_o = comp_i._this()
+ return comp_o
+
+ #-------------------------------------------------------------------------
+
def load_impl(self, nameToRegister, componentName):
MESSAGE( "SALOME_ContainerPy_i::load_impl " + str(nameToRegister) + ' ' + str(componentName) )
self._numInstance = self._numInstance +1
def remove_impl(self, component):
MESSAGE( "SALOME_ContainerPy_i::remove_impl" )
+ return None
#-------------------------------------------------------------------------
def finalize_removal(self):
MESSAGE( "SALOME_ContainerPy_i::finalize_removal" )
+ return None
#-------------------------------------------------------------------------
def ping(self):
MESSAGE( "SALOME_ContainerPy_i::ping" )
+ return None
#-------------------------------------------------------------------------
def _get_name(self):
MESSAGE( "SALOME_ContainerPy_i::_get_name" )
+ return self._containerName
#-------------------------------------------------------------------------
Engines::Component_ptr load_impl(const char* nameToRegister,
const char* componentName);
+ Engines::Component_ptr instance(const char* nameToRegister,
+ const char* componentName);
+
//! Unload component from current container
void remove_impl(Engines::Component_ptr component_i);
void finalize_removal();
--- /dev/null
+#include <Launchers.hxx>
+
+static int Launchers_IsLoaded = 0;
+static PyObject * Launchers_module = 0;
+static char * Launchers_name="Launchers";
+
+PyThreadState *mainThreadState=0;
+
+PyThreadState * getMainThreadState(){
+ PyInterpreterState *interp;
+ PyThreadState *p;
+ interp=PyInterpreterState_Head();
+ for (interp = PyInterpreterState_Head(); interp != NULL; ){
+ if(interp->next == NULL)break;
+ interp=interp->next;
+ }
+ for (p = interp->tstate_head; p != NULL; ){
+ if(p->next == NULL)break;
+ p=p->next;
+ }
+ return p;
+}
+PyThreadState *acquireMainThread(){
+ PyEval_AcquireLock();
+ return PyThreadState_Swap(mainThreadState);
+}
+void releaseMainThread(PyThreadState *tstate){
+ PyThreadState_Swap(tstate);
+ PyEval_ReleaseLock();
+}
+
+void Launchers_assertInitialized() {
+ PyThreadState *_save;
+ if( !Py_IsInitialized() ) {
+ Py_Initialize();
+ PyEval_InitThreads();
+ PyEval_SaveThread();
+ }
+ if( !Launchers_IsLoaded ) {
+ mainThreadState=getMainThreadState();
+ _save=acquireMainThread();
+ Launchers_module=PyImport_ImportModule(Launchers_name);
+ if(!Launchers_module){
+ PyErr_Print();
+ return;
+ }
+ Py_INCREF(Launchers_module);
+ Launchers_IsLoaded = 1;
+ releaseMainThread(_save);
+ }
+}
+
+PyObject * getLauncher(char* arg0) {
+ PyObject *v;
+ PyThreadState *_save;
+ Launchers_assertInitialized();
+ _save=acquireMainThread();
+ v=PyObject_CallMethod(Launchers_module,"getLauncher","s",arg0);
+ if(!v){
+ PyErr_Print();
+ return NULL;
+ }
+ releaseMainThread(_save);
+ Py_INCREF(v);
+ return v;
+}
+
+void Launcher_Slaunch(PyObject *self, char* arg1, char* arg2) {
+ PyObject *v;
+ PyThreadState *_save;
+ Launchers_assertInitialized();
+ _save=acquireMainThread();
+ v=PyObject_CallMethod(self,"Slaunch","ss",arg1,arg2);
+ if(!v){
+ PyErr_Print();
+ }
+ releaseMainThread(_save);
+}
+
--- /dev/null
+#include <Python.h>
+#define elDEBUG 0
+
+PyObject * getLauncher(char* );
+void Launcher_Slaunch(PyObject * objId, char*, char* );
+
--- /dev/null
+import os
+import Utils_Identity
+import ConfigParser
+
+class Config:
+ defaults={'user':'','opt':''}
+ def __init__(self):
+ self.config=ConfigParser.ConfigParser(self.defaults)
+ self.config.read(os.path.join(os.environ['HOME'],Utils_Identity.getapplipath(),'launchers.cfg'))
+ def computers(self):
+ return self.config.sections()
+ def options(self,computer):
+ if not self.config.has_section(computer):
+ return self.defaults
+ else:
+ d={}
+ for opt in self.config.options(computer):
+ d[opt]=self.config.get(computer,opt)
+ return d
+
+config=None
+def setConfig(conf):
+ global config
+ config=conf
+
+setConfig(Config())
+
+class Launcher:
+ def Slaunch(self,computer,CMD):
+ self.launch(computer,CMD.split())
+
+class SSH(Launcher):
+ def launch(self,computer,CMD):
+ print computer,CMD
+ conf=config.options(computer)
+ print conf
+ command=["ssh",computer]
+ if conf["user"]:
+ command=command+['-l',conf["user"]]
+ if conf["opt"]:
+ command=command+string.split(conf["opt"])
+ command=command+[os.path.join(Utils_Identity.getapplipath(),'runSession')]+CMD
+ command=command+['>', "/tmp/" + CMD[1] + "_" + computer + ".log 2>&1"]
+
+ print command
+ pid = os.spawnvp(os.P_NOWAIT, command[0], command)
+
+launcher=None
+_register={}
+
+def register(name,klass):
+ _register[name]=klass
+
+register("ssh",SSH())
+
+def setLauncher(name):
+ global launcher
+ launcher=_register[name]
+
+def getLauncher(computer):
+ """
+ Return a launcher for the computer
+ If can be specified in config
+ If not return the default one : launcher
+ """
+ conf=config.options(computer)
+ name=conf.get("launcher","")
+ return _register.get(name,launcher)
+
+setLauncher("ssh")
+
+try:
+ # Try to import a plugin module (user defined) that
+ # can define other launchers and register them
+ # 1- define a class
+ # 2- register it with : Launchers.register(name,klass)
+ # 3- eventually set it as default one : Launchers.setLauncher(name)
+ import pluginLauncher
+except:
+ import traceback
+ traceback.print_exc()
+ pass
from SALOME_utilities import *
from Utils_Identity import getShortHostName
+import Utils_Identity
+import Launchers
class LifeCycleCORBA:
_orb = None
except:
theComputer = ""
theContainer = containerName
- if theComputer == "" :
- theComputer = getShortHostName()
- if theComputer == "localhost" :
+
+ if theComputer in ("","localhost") :
theComputer = getShortHostName()
- computerSplitName = theComputer.split('.')
- theComputer = computerSplitName[0]
+
MESSAGE( theComputer + theContainer )
return theComputer,theContainer
#-------------------------------------------------------------------------
+ def setLauncher(self,name):
+ """Change default launcher to the launcher identified by name
+
+ See module Launchers.py
+ """
+ Launchers.setLauncher(name)
+
+ #-------------------------------------------------------------------------
+
+ def StartContainer(self, theComputer , theContainer ):
+ """Start a container on theComputer machine with theContainer name
+ """
+ # Get the Naming Service address
+ #
+ addr=self._orb.object_to_string(self._rootContext)
+ #
+ # If container name contains "Py" launch a Python Container
+ #
+ if theContainer.find('Py') == -1 :
+ CMD=['SALOME_Container',theContainer,'-ORBInitRef','NameService='+addr]
+ else:
+ CMD=['SALOME_ContainerPy.py',theContainer,'-ORBInitRef','NameService='+addr]
+ if theComputer in ("","localhost"):
+ theComputer=getShortHostName()
+ #
+ # Get the appropriate launcher and ask to launch
+ #
+ Launchers.getLauncher(theComputer).launch(theComputer,CMD)
+ #
+ # Wait until the container is registered in Naming Service
+ #
+ count =5
+ aContainer=None
+ while aContainer is None and count > 0:
+ time.sleep(1)
+ count = count - 1
+ MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer )
+ aContainer = self.FindContainer( theComputer + "/" + theContainer )
+ return aContainer
+
+ #-------------------------------------------------------------------------
+
+ def FindOrStartContainer(self, theComputer , theContainer ):
+ """Find or Start a container on theComputer machine with theContainer name
+ """
+ if theComputer in ("","localhost"):
+ theComputer=getShortHostName()
+ MESSAGE( "FindOrStartContainer: " + theComputer + theContainer )
+ aContainer = self.FindContainer( theComputer + "/" + theContainer )
+ if aContainer is None :
+ aContainer= self.StartContainer(theComputer , theContainer )
+ return aContainer
+
+ #-------------------------------------------------------------------------
+
def LoadComponent(self,containerName,componentName,listOfMachine):
container=self._contManager.FindOrStartContainer(containerName,listOfMachine)
implementation="lib"+componentName+"Engine.so"
EXPORT_HEADERS = SALOME_LifeCycleCORBA.hxx
-EXPORT_PYSCRIPTS = LifeCycleCORBA.py
+EXPORT_PYSCRIPTS = LifeCycleCORBA.py Launchers.py
# Libraries targets
LIB = libSalomeLifeCycleCORBA.la
-LIB_SRC = SALOME_LifeCycleCORBA.cxx
+LIB_SRC = SALOME_LifeCycleCORBA.cxx Launchers.cxx
LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl
BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl
-CPPFLAGS += $(QT_MT_INCLUDES)
+CPPFLAGS += $(PYTHON_INCLUDES) $(QT_MT_INCLUDES)
LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSalomeContainer -lSalomeResourcesManager
LDFLAGSFORBIN= $(LDFLAGS) -lRegistry -lSalomeNotification -lSALOMETraceCollector
+LIBS += $(PYTHON_LIBS)
@CONCLUDE@
#include "OpUtil.hxx"
#include "utilities.h"
+#include "Launchers.hxx"
#include <ServiceUnreachable.hxx>
string implementation=Engines_Component_i::GetDynLibraryName(componentName);
return cont->load_impl(componentName, implementation.c_str());
}
+
+
+Engines::Container_ptr SALOME_LifeCycleCORBA::FindOrStartContainer(
+ const string aComputerContainer ,
+ const string theComputer ,
+ const string theContainer ) {
+ SCRUTE( aComputerContainer ) ;
+ SCRUTE( theComputer ) ;
+ SCRUTE( theContainer ) ;
+
+ Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ;
+
+ if ( !CORBA::is_nil( aContainer ) ) {
+ return aContainer ;
+ }
+
+ Engines::Container_var aFactoryServer ;
+
+ bool pyCont = false ;
+ int len = theContainer.length() ;
+ if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) {
+ pyCont = true ;
+ }
+
+ string addr=_NS->getIORaddr();
+ string CMD="SALOME_Container";
+ if ( pyCont ) {
+ CMD="SALOME_ContainerPy.py";
+ }
+ CMD=CMD + " " + theContainer;
+ CMD=CMD + " -ORBInitRef NameService="+addr;
+
+ /*
+ * Get the appropriate launcher and ask to launch
+ */
+ PyObject * launcher=getLauncher((char *)theComputer.c_str());
+ Launcher_Slaunch(launcher,(char *)theComputer.c_str(),(char *)CMD.c_str());
+ /*
+ * Wait until the container is registered in Naming Service
+ */
+ int count = 5 ;
+ while ( CORBA::is_nil( aFactoryServer ) && count ) {
+ sleep( 1 ) ;
+ count-- ;
+ if ( count != 10 )
+ MESSAGE( count << ". Waiting for FactoryServer on " << theComputer)
+ aFactoryServer = FindContainer( aComputerContainer.c_str() ) ;
+ }
+ if ( !CORBA::is_nil( aFactoryServer ) ) {
+ return aFactoryServer;
+ }
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ;
+ return Engines::Container::_nil();
+}
std::string * theComputer ,
std::string * theContainer ) ;
std::string ComputerPath( const char * theComputer ) ;
+ Engines::Container_ptr FindOrStartContainer(const std::string aComputerContainer ,
+ const std::string theComputer ,
+ const std::string theContainer ) ;
} ;
#endif
// Module : SALOME
// $Header$
-#include "utilities.h"
#include <iostream>
#include <unistd.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "utilities.h"
+#include "SALOMETraceCollector.hxx"
#include <OpUtil.hxx>
+
using namespace std;
int main (int argc, char * argv[])
{
// Initializing omniORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
// Obtain a reference to the root POA
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
string containerName = GetHostname();
+ cout << containerName << endl;
+ cout << "FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" << endl;
+ MESSAGE("FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" );
+
Engines::Component_var mycompo =
_LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
ASSERT(!CORBA::is_nil(m2));
SCRUTE(m2->instanceName());
+ cout << m2->instanceName() << endl;
MESSAGE("Coucou " << m2->Coucou(1L));
+
+ Engines::Component_var mycompo3 = _LCC.FindOrLoad_Component("totoPy","SALOME_TestComponentPy");
+ ASSERT(!CORBA::is_nil(mycompo3));
+ Engines::TestComponent_var m3 = Engines::TestComponent::_narrow(mycompo3);
+ ASSERT(!CORBA::is_nil(m3));
+ cout << m3->instanceName() << endl;
+
+ string containerName4 = containerName + "/titiPy";
+ Engines::Component_var mycompo4 = _LCC.FindOrLoad_Component(containerName4.c_str(),"SALOME_TestComponentPy");
+ ASSERT(!CORBA::is_nil(mycompo4));
+ Engines::TestComponent_var m4 = Engines::TestComponent::_narrow(mycompo4);
+ ASSERT(!CORBA::is_nil(m4));
+ cout << m4->instanceName() << endl;
+
}
catch(CORBA::COMM_FAILURE& ex)
{
#if !defined(AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_)
#define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_
-#include <strstream.h>
+#include <strstream>
#include "Logger.hh"
//these declarations for files don't using OCC includes (for example HDF)
}
//----------------------------------------------------------------------
+
+char * SALOME_NamingService::getIORaddr(){
+ return _orb->object_to_string(_root_context);
+}
virtual void Destroy_Directory(const char* Path)
throw(ServiceUnreachable);
+ //! get IORstring naming service address
+ char * getIORaddr();
+
protected:
CORBA::ORB_ptr _orb;
CosNaming::NamingContext_var _root_context, _current_context;
$(CURDIR)/sipSalomePyQtSalomePyQt.cc \
$(CURDIR)/sipSalomePyQtSALOME_Selection.cc
+ifeq ($(SIP_VERS),new2)
+MOC_SRC = SalomePyQtcmodule_moc.cxx
+MOC_H = SalomePyQtcmodule.h
+else
+MOC_SRC = sipSalomePyQtProxySalomePyQt_moc.cxx
+MOC_H = sipSalomePyQtProxySalomePyQt.h
+endif
+
# Libraries targets
LIB = libSalomePyQtcmodule.la
-MOC_SRC = sipSalomePyQtProxySalomePyQt_moc.cxx
-
LIB_SRC += SalomePyQt.cxx SALOME_PYQT_GUI.cxx $(SIP_SRC) $(MOC_SRC)
LIB_MOC = SALOME_PYQT_GUI.h
$(SIP_SRC): $(SIP_FILES)
$(SIP) $(SIP_FLAGS) $<
-$(MOC_SRC): sipSalomePyQtProxySalomePyQt.h
+$(MOC_SRC): $(MOC_H)
$(MOC) $< -o $@
@CONCLUDE@
self._tc_start = time.time()
self._cstart = time.ctime(self._tc_start)
self._cdir = os.getcwd()
+
+def getapplipath():
+ """
+ Gives short application path (the complete path is $HOME/$APPLI)
+ """
+ return os.environ.get("APPLI",".salome_"+versnb)
+
+try:
+ file = open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r")
+ s = file.readline()
+ versnb = string.strip(string.split(s, ":")[1])
+ dirname=".salome_"+versnb
+except:
+ versnb = ""
+ dirname=".salome"
+
+def version():
+ """
+ Gives salome version number
+ """
+ return versnb