Back to index

salome-kernel  6.5.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
SALOME_ContainerPy.SALOME_ContainerPy_i Class Reference

List of all members.

Public Member Functions

def __init__
def start_impl
def instance
def load_impl
def import_component
def load_component_Library
def create_component_instance_env
def create_component_instance
def find_component_instance
def remove_impl
def finalize_removal
def ping
def getPID
def getHostName
def Shutdown

Private Member Functions

def _get_name
def _get_machineName
def _get_logfilename
def _set_logfilename
def _get_workingdir

Private Attributes

 _containerName
 _naming_service
 _numInstance
 _machineName
 _logfilename

Static Private Attributes

 _orb = None
 _poa = None
int _numInstance = 0
dictionary _listInstances_map = {}

Detailed Description

Definition at line 49 of file SALOME_ContainerPy.py.


Constructor & Destructor Documentation

def SALOME_ContainerPy.SALOME_ContainerPy_i.__init__ (   self,
  orb,
  poa,
  containerName 
)

Definition at line 57 of file SALOME_ContainerPy.py.

00057 
00058     def __init__(self, orb, poa, containerName):
00059         MESSAGE( "SALOME_ContainerPy_i::__init__" )
00060         self._orb = orb
00061         self._poa = poa
00062         myMachine=getShortHostName()
00063         Container_path = "/Containers/" + myMachine + "/" + containerName
00064         self._containerName = Container_path
00065         if verbose(): print "container name ",self._containerName
00066 
00067         naming_service = SALOME_NamingServicePy_i(self._orb)
00068         self._naming_service = naming_service
00069         MESSAGE( str(Container_path) )
00070         naming_service.Register(self._this(), Container_path)
            

Here is the call graph for this function:


Member Function Documentation

Definition at line 304 of file SALOME_ContainerPy.py.

00304 
00305     def _get_logfilename(self):
      return self._logfilename

Definition at line 291 of file SALOME_ContainerPy.py.

00291 
00292     def _get_machineName(self):
00293         MESSAGE( "SALOME_ContainerPy_i::_get_MachineName" )
00294         self._machineName = "localhost"
00295         return self._machineName

Definition at line 278 of file SALOME_ContainerPy.py.

00278 
00279     def _get_name(self):
00280         MESSAGE( "SALOME_ContainerPy_i::_get_name" )
00281         return self._containerName

Definition at line 308 of file SALOME_ContainerPy.py.

00308 
00309     def _get_workingdir(self):
00310       return os.getcwd()
00311 
00312 #=============================================================================

def SALOME_ContainerPy.SALOME_ContainerPy_i._set_logfilename (   self,
  logfilename 
) [private]

Definition at line 306 of file SALOME_ContainerPy.py.

00306 
00307     def _set_logfilename(self,logfilename):
      self._logfilename=logfilename
def SALOME_ContainerPy.SALOME_ContainerPy_i.create_component_instance (   self,
  componentName,
  studyId 
)

Definition at line 205 of file SALOME_ContainerPy.py.

00205 
00206     def create_component_instance(self, componentName, studyId):
00207         MESSAGE( "SALOME_ContainerPy_i::create_component_instance ==> " + str(componentName) + ' ' + str(studyId) )
00208         if studyId < 0:
00209             MESSAGE( "Study ID is lower than 0!" )
00210             return None
00211         else:
00212             self._numInstance = self._numInstance +1
00213             instanceName = componentName + "_inst_" + `self._numInstance`
00214             comp_iors=""
00215             try:
00216                 component=__import__(componentName)
00217                 factory=getattr(component,componentName)
00218                 comp_i=factory(self._orb,
00219                                self._poa,
00220                                self._this(),
00221                                self._containerName,
00222                                instanceName,
00223                                componentName)
00224                 
00225                 MESSAGE( "SALOME_Container_i::create_component_instance : OK")
00226                 comp_o = comp_i._this()
00227                 self._listInstances_map[instanceName] = comp_i
00228             except:
00229                 import traceback
00230                 traceback.print_exc()
00231                 MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK")
00232             return comp_o

Here is the caller graph for this function:

def SALOME_ContainerPy.SALOME_ContainerPy_i.create_component_instance_env (   self,
  componentName,
  studyId,
  env 
)

Definition at line 202 of file SALOME_ContainerPy.py.

00202 
00203     def create_component_instance_env(self, componentName, studyId, env):
00204       return self.create_component_instance(componentName, studyId), ""

Here is the call graph for this function:

Definition at line 261 of file SALOME_ContainerPy.py.

00261 
00262     def finalize_removal(self):
00263         MESSAGE( "SALOME_ContainerPy_i::finalize_removal" )
00264         return None

def SALOME_ContainerPy.SALOME_ContainerPy_i.find_component_instance (   self,
  registeredName,
  studyId 
)

Definition at line 235 of file SALOME_ContainerPy.py.

00235 
00236     def find_component_instance(self, registeredName, studyId):
00237         anEngine = None
00238         keysList = self._listInstances_map.keys()
00239         i = 0
00240         while i < len(keysList):
00241             instance = keysList[i]
00242             if find(instance,registeredName) == 0:
00243                 anEngine = self._listInstances_map[instance]
00244                 if studyId == anEngine.getStudyId():
00245                     return anEngine._this()
00246             i = i + 1
00247         return anEngine._this()
00248         
        

Definition at line 284 of file SALOME_ContainerPy.py.

00284 
00285     def getHostName(self):
00286         MESSAGE( "SALOME_ContainerPy_i::_get_MachineName" )
00287         self._machineName = "localhost"
00288         return self._machineName

Definition at line 273 of file SALOME_ContainerPy.py.

00273 
00274     def getPID(self):
00275         return os.getpid()

def SALOME_ContainerPy.SALOME_ContainerPy_i.import_component (   self,
  componentName 
)

Definition at line 169 of file SALOME_ContainerPy.py.

00169 
00170     def import_component(self, componentName):
00171         MESSAGE( "SALOME_Container_i::import_component" )
00172         reason = ""
00173         try:
00174             if verbose(): print "try import %s" % componentName
00175             # try import component
00176             module=__import__(componentName)
00177             if verbose(): print "import %s is done successfully" % componentName
00178             # if import successfully, check that component is loadable
00179             if not hasattr(module, componentName):
00180                 reason = "module %s is not loadable" % componentName
00181                 print reason
00182                 pass
00183             pass
00184         except:
00185             import traceback
00186             print "cannot import %s" % componentName
00187             traceback.print_exc()
00188             reason = "cannot import %s" % componentName
00189         return reason

Here is the caller graph for this function:

def SALOME_ContainerPy.SALOME_ContainerPy_i.instance (   self,
  nameToRegister,
  componentName 
)

Definition at line 138 of file SALOME_ContainerPy.py.

00138 
00139     def instance(self, nameToRegister, componentName):
00140         MESSAGE(  "SALOME_ContainerPy_i::instance " + str(nameToRegister) + ' ' + str(componentName) )
00141         self._numInstance = self._numInstance +1
00142         instanceName = nameToRegister + "_inst_" + `self._numInstance`
00143 
00144         component=__import__(componentName)
00145         factory=getattr(component,componentName)
00146         comp_i=factory(self._orb, self._poa, self._this(), self._containerName,
00147                        instanceName, nameToRegister)
00148 
00149         MESSAGE( "SALOME_ContainerPy_i::instance : component created")
00150         comp_o = comp_i._this()
00151         return comp_o

Definition at line 192 of file SALOME_ContainerPy.py.

00192 
00193     def load_component_Library(self, componentName):
00194         MESSAGE(  "SALOME_ContainerPy_i::load_component_Library " + str(componentName) )
00195         ret = 0
00196         instanceName = componentName + "_inst_" + `self._numInstance`
00197         interfaceName = componentName
00198         reason = self.import_component(componentName)
00199         return reason == "", reason
    

Here is the call graph for this function:

def SALOME_ContainerPy.SALOME_ContainerPy_i.load_impl (   self,
  nameToRegister,
  componentName 
)

Definition at line 154 of file SALOME_ContainerPy.py.

00154 
00155     def load_impl(self, nameToRegister, componentName):
00156         MESSAGE(  "SALOME_ContainerPy_i::load_impl " + str(nameToRegister) + ' ' + str(componentName) )
00157         self._numInstance = self._numInstance +1
00158         instanceName = nameToRegister + "_inst_" + `self._numInstance`
00159         interfaceName = nameToRegister
00160         the_command = "import " + nameToRegister + "\n"
00161         the_command = the_command + "comp_i = " + nameToRegister + "." + nameToRegister
00162         the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n"
00163         MESSAGE( "SALOME_ContainerPy_i::load_impl :" + str (the_command) )
00164         exec the_command
00165         comp_o = comp_i._this()
00166         return comp_o
    

Definition at line 267 of file SALOME_ContainerPy.py.

00267 
00268     def ping(self):
00269         MESSAGE( "SALOME_ContainerPy_i::ping() pid " + str(os.getpid()) )
00270         return None

def SALOME_ContainerPy.SALOME_ContainerPy_i.remove_impl (   self,
  component 
)

Definition at line 251 of file SALOME_ContainerPy.py.

00251 
00252     def remove_impl(self, component):
00253         MESSAGE( "SALOME_ContainerPy_i::remove_impl" )
00254         instanceName = component._get_instanceName()
00255         MESSAGE( "unload component " + str(instanceName) )
00256         self._listInstances_map.remove(instanceName)
00257         component.destroy()
00258         self._naming_service.Destroy_Name(str(instanceName))

Definition at line 298 of file SALOME_ContainerPy.py.

00298 
00299     def Shutdown(self):
00300         self._naming_service.Destroy_Name(self._containerName);
00301         self._naming_service.Destroy_FullDirectory(self._containerName);
00302         self._orb.shutdown(0)
00303         pass

def SALOME_ContainerPy.SALOME_ContainerPy_i.start_impl (   self,
  ContainerName 
)

Definition at line 73 of file SALOME_ContainerPy.py.

00073 
00074     def start_impl(self, ContainerName):
00075         MESSAGE(  "SALOME_ContainerPy_i::start_impl " + str(ContainerName) )
00076         myMachine=getShortHostName()
00077         theContainer = "/Containers/" + myMachine + "/" + ContainerName
00078         try:
00079             obj = self._naming_service.Resolve(theContainer)
00080         except :
00081             obj = None
00082             MESSAGE(  "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object not found in Naming Service" )
00083         if obj is None:
00084             container = None
00085         else:
00086             container = obj._narrow(Engines.Container)
00087             if container is None:
00088                 MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(containerName) + ".object exists but is not a Container" )
00089             else :
00090                 MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without new launch" )
00091             return container
00092         #shstr = os.getenv( "PWD" ) + "/"
00093         #shstr += "runSession ./SALOME_ContainerPy.py "
00094         shstr = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/SALOME_ContainerPy.py ";
00095         #shstr = "runSession SALOME_ContainerPy.py "
00096         shstr += ContainerName
00097 
00098         # mpv: fix for SAL4731 - allways create new file to write log of server
00099         num = 1
00100         fileName = ""
00101         while 1:
00102             fileName = "/tmp/"+ContainerName+"_%i.log"%num
00103             if not os.path.exists(fileName):
00104                 break
00105             num += 1
00106             pass
00107         
00108         shstr += " > "
00109         shstr += fileName
00110         shstr += " 2>&1 &"
00111         
00112         #shstr += " > /tmp/"
00113         #shstr += ContainerName
00114         #shstr += ".log 2>&1 &"
00115         
00116         MESSAGE(  "SALOME_ContainerPy_i::start_impl " + "os.system(" + str(shstr) + ")" )
00117         os.system( shstr )
00118         count = 21
00119         while container is None :
00120             time.sleep(1)
00121             count = count - 1
00122             MESSAGE(  str(count) + ". Waiting for " + str(theContainer) )
00123             try :
00124                 obj = self._naming_service.Resolve(theContainer)
00125             except :
00126                 obj = None
00127             if obj is None:
00128                 container = None
00129             else:
00130                 container = obj._narrow(Engines.Container)
00131                 if container is None:
00132                     MESSAGE(  str(containerName) + ".object exists but is not a Container" )
00133                 return container
00134             if count == 0 :
00135                 return container

Here is the call graph for this function:


Member Data Documentation

Definition at line 63 of file SALOME_ContainerPy.py.

Definition at line 53 of file SALOME_ContainerPy.py.

Definition at line 307 of file SALOME_ContainerPy.py.

Definition at line 286 of file SALOME_ContainerPy.py.

Definition at line 67 of file SALOME_ContainerPy.py.

Definition at line 52 of file SALOME_ContainerPy.py.

Definition at line 140 of file SALOME_ContainerPy.py.

Definition at line 50 of file SALOME_ContainerPy.py.

Definition at line 51 of file SALOME_ContainerPy.py.


The documentation for this class was generated from the following file: