Back to index

salome-kernel  6.5.0
Classes | Functions | Variables
salome_session Namespace Reference

Module that provides the SalomeSession object that helps to launch a SALOME script session. More...

Classes

class  SalomeSession

Functions

def startSession
def getShortHostName
def searchFreePort

Variables

 _session = None

Detailed Description

Module that provides the SalomeSession object that helps to launch a SALOME script session.


Function Documentation

gives Hostname without domain extension.
SALOME naming service needs short Hostnames (without domain extension).
HOSTNAME is not allways defined in environment,
socket.gethostname() gives short or complete Hostname, depending on
defined aliases.

Definition at line 43 of file salome_session.py.

00043 
00044 def getShortHostName():
00045     """
00046     gives Hostname without domain extension.
00047     SALOME naming service needs short Hostnames (without domain extension).
00048     HOSTNAME is not allways defined in environment,
00049     socket.gethostname() gives short or complete Hostname, depending on
00050     defined aliases.
00051     """
00052     from salome_utils import getShortHostName
00053     return getShortHostName()

Here is the caller graph for this function:

Search free port for SALOME session.
Returns first found free port number.

Definition at line 54 of file salome_session.py.

00054 
00055 def searchFreePort():
00056     """
00057     Search free port for SALOME session.
00058     Returns first found free port number.
00059     """
00060     print "Searching a free port for naming service:",
00061     from salome_utils import generateFileName, getHostName
00062     hostname = getHostName()
00063     NSPORT = 2810
00064     limit  = NSPORT+100
00065     while 1:
00066         print "%s "%(NSPORT),
00067         status = os.system("netstat -ltn | grep -E :%s"%(NSPORT))
00068         if status:
00069             home  = os.getenv("HOME")
00070             appli = os.getenv("APPLI")
00071             kwargs={}
00072             if appli is not None: 
00073               home = os.path.join(home, appli,"USERS")
00074               kwargs["with_username"]=True
00075             omniorb_config = generateFileName(home, prefix="omniORB",
00076                                               extension="cfg",
00077                                               hidden=True,
00078                                               with_hostname=True,
00079                                               with_port=NSPORT,
00080                                               **kwargs)
00081             f = open(omniorb_config, "w")
00082             f.write("ORBInitRef NameService=corbaname::%s:%s\n"%(hostname, NSPORT))
00083             f.close()
00084             os.environ['OMNIORB_CONFIG'] = omniorb_config
00085             last_running_config = generateFileName(home, prefix="omniORB",
00086                                                    suffix="last",
00087                                                    extension="cfg",
00088                                                    hidden=True,
00089                                                    **kwargs)
00090             os.environ['LAST_RUNNING_CONFIG'] = last_running_config
00091             if os.access(last_running_config,os.F_OK):
00092                 os.unlink(last_running_config)
00093                 pass
00094             os.symlink(omniorb_config,last_running_config)
00095             print "- Ok"
00096             break
00097         if NSPORT == limit:
00098             msg  = ""
00099             msg += "Can not find a free port to launch omniNames\n"
00100             msg += "Kill the running servers and try again.\n"
00101             raise RuntimeError, msg
00102         NSPORT = NSPORT+1
00103         pass
00104     os.environ['NSHOST'] = hostname
00105     os.environ['NSPORT'] = str(NSPORT)
00106     return NSPORT
00107 

Here is the call graph for this function:

Here is the caller graph for this function:

def salome_session.startSession (   modules = [])

Definition at line 36 of file salome_session.py.

00036 
00037 def startSession(modules=[]):
00038     global _session
00039     if _session: return
00040     searchFreePort()
00041     _session = SalomeSession(modules)
00042     return

Here is the call graph for this function:


Variable Documentation

Definition at line 34 of file salome_session.py.