Salome HOME
CCAR: some corrections in :
[modules/kernel.git] / src / Container / SALOME_ContainerPy.py
index 0ee6b8cd06c524bd455c2c755cbfcc2de9469a6c..41cfcaeee9df9ad9b003044658ecb9045b6ec8d6 100755 (executable)
@@ -19,7 +19,7 @@
 #  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 #
 #
@@ -31,7 +31,7 @@
 import os
 import sys
 import string
-import omnipatch                     # PAL10310
+
 from omniORB import CORBA, PortableServer
 import SALOMEDS 
 import Engines, Engines__POA
@@ -40,6 +40,7 @@ from SALOME_ComponentPy import *
 
 from SALOME_utilities import *
 from Utils_Identity import getShortHostName
+from launchConfigureParser import verbose
 
 #=============================================================================
 
@@ -61,7 +62,7 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         Container_path = "/Containers/" + myMachine + "/" + containerName
         #self._containerName = containerName
         self._containerName = Container_path
-        print "container name ",self._containerName
+        if verbose(): print "container name ",self._containerName
 
         naming_service = SALOME_NamingServicePy_i(self._orb)
         self._naming_service = naming_service
@@ -140,10 +141,10 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         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)
+        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()
@@ -170,9 +171,9 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         MESSAGE( "SALOME_Container_i::import_component" )
         ret=0
         try:
-            print "try import ",componentName
-            __import__(componentName)
-            print "import ",componentName," successful"
+            if verbose(): print "try import ",componentName
+            module=__import__(componentName)
+            if verbose(): print "import ",componentName," successful"
             ret=1
         except:
             import traceback
@@ -303,31 +304,42 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
     #-------------------------------------------------------------------------
 
     def Shutdown(self):
+        self._naming_service.Destroy_Name(self._containerName);
+        self._naming_service.Destroy_FullDirectory(self._containerName);
         self._orb.shutdown(0)
         pass
 
-#=============================================================================
-
-#initialise the ORB and find the root POA
-orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
-poa = orb.resolve_initial_references("RootPOA")
-
-#create an instance of SALOME_ContainerPy_i and a Container reference
-#containerName = "FactoryServerPy"
-MESSAGE( str(sys.argv) )
-containerName = sys.argv[1]
-cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
-cpy_o = cpy_i._this()
-
-#activate the POA
-poaManager = poa._get_the_POAManager()
-poaManager.activate()
-
-#Block for ever
-orb.run()
-
-
-        
-            
+    def _get_logfilename(self):
+      return self._logfilename
+    def _set_logfilename(self,logfilename):
+      self._logfilename=logfilename
+    def _get_workingdir(self):
+      return os.getcwd()
 
+#=============================================================================
 
+if __name__ == "__main__":
+  #initialise the ORB and find the root POA
+  if verbose():print "Starting ",sys.argv[1]
+  orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+  poa = orb.resolve_initial_references("RootPOA")
+  if verbose():print "ORB and POA initialized"
+
+  #create an instance of SALOME_ContainerPy_i and a Container reference
+  #containerName = "FactoryServerPy"
+  MESSAGE( str(sys.argv) )
+  containerName = sys.argv[1]
+  cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
+  if verbose():print "SALOME_ContainerPy_i instance created ",cpy_i 
+  cpy_o = cpy_i._this()
+  if verbose():print "SALOME_ContainerPy_i instance activated ",cpy_o
+  sys.stdout.flush()
+  sys.stderr.flush()
+
+  #activate the POA
+  poaManager = poa._get_the_POAManager()
+  poaManager.activate()
+
+  #Block for ever
+  orb.run()
+  if verbose():print "SALOME_ContainerPy_i shutdown"