envSalome.py \
salomeConsole.py \
showNS.py \
-addToKillList.py
+addToKillList.py \
+NSparam.py
# copy header files in common directory
OWN_CONFIG_H=@OWN_CONFIG_H@
--- /dev/null
+#!/usr/bin/env python
+
+import sys,os
+import string
+
+def getNSparams(info=""):
+ """
+ check environment for omniORB configuration file.
+ parse the file to find the line defining naming service host and port,
+ set environment variables NSPORT and NSHOST,
+ get host and port,
+ if info==host print host
+ elif info==port print host
+ else print 2 strings on stdout on one line: host port
+ """
+ my_port=""
+ my_host=""
+ if os.environ.has_key("OMNIORB_CONFIG"):
+ file = open(os.environ["OMNIORB_CONFIG"], "r")
+ s = file.read()
+ while len(s):
+ l = string.split(s, ":")
+ if string.split(l[0], " ")[0] == "ORBInitRef" or \
+ string.split(l[0], " ")[0] == "InitRef" :
+ my_port = l[len(l)-1]
+ if my_port[-1] == '\n':
+ my_port = my_port[:-1]
+ pass
+ my_host = l[len(l)-2]
+ break;
+ pass
+ s = file.read()
+ pass
+ pass
+ if info=='host':
+ # keep print, stdout used in shell
+ print my_host
+ os.environ['NSHOST']=my_host
+ return my_host
+ pass
+ elif info=='port':
+ # keep print, stdout used in shell
+ print my_port
+ os.environ['NSPORT']=my_port
+ return my_port
+ pass
+ else:
+ # keep print, stdout used in shell
+ print my_host, my_port
+ return my_host, my_port
+ pass
+
+# ------------------------------------------------------------------------
+
+if __name__ == "__main__":
+ if len(sys.argv) >1:
+ if sys.argv[1]=='host':
+ getNSparams('host')
+ pass
+ elif sys.argv[1]=='port':
+ getNSparams('port')
+ pass
+ else:
+ getNSparams('')
+ pass
+ pass
+ else:
+ getNSparams('')
+ pass
See SALOME_Application_ to define your own configuration of SALOME and run it
on one or several computers. This is the recommended way of configuration.
-.. _SALOME_Application: ./doc/SALOME_Application.html
+.. _SALOME_Application: ../../doc/SALOME_Application.html
User run scripts
----------------
-The SALOME user can use 4 scripts:
+The SALOME user can use the following scripts:
runAppli
Launches a SALOME Session
It is also possible to use runSession, then python.
runTests
- Similar to runSession, used for unit testing. runSession tries to use an
- already existing naming service definition from a running session (hostname
- and port number), runTests defines a new configuration for naming service
- (new port number).
+ Similar to runSession, used for unit testing. runTests defines a new
+ configuration for naming service (new port number) to avoid interferences
+ with a running SALOME session. runSession tries to use an already existing
+ naming service definition from a running session (hostname & port number).
+
+killCurrentPort
+ Kills the last SALOME session corresponding to this application, and
+ intially launched from this computer.
+ Cleans associated config files.
SALOME internal run scripts
---------------------------
envd
Sets SALOME application environment, envd is sourced by other scripts.
+setAppliPath.sh
+ Used by other scripts to define the Application Path.
+
+searchFreePort.sh
+ Used by other scripts to find a free port for naming service.
+
For remote calls, SALOME uses one script.
runRemote.sh
define the hostname and port userd for naming service, the remaining
arguments define the command to execute.
+
The following files must be adapted to your environment and SALOME Application
------------------------------------------------------------------------------
--- /dev/null
+#!/bin/bash
+
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
+
+# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
+
+. ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
+
+# --- find omniORB configuration relative to current session if any
+
+myhost=`hostname`
+fileOmniConfig=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+
+if [ -f $fileOmniConfig ]; then
+ export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+fi
+
+currentPort=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port`
+echo $currentPort
+
+# --- kill current salome session
+
+${KERNEL_ROOT_DIR}/bin/salome/killSalomeWithPort.py $currentPort
+
+# --- delete config files
+
+if [ -s $fileOmniConfig ]; then
+ refConfig=`ls -l $fileOmniConfig | awk '{print \$NF}'`
+ if [ -f $refConfig ]; then
+ rm $refConfig
+ fi
+ rm $fileOmniConfig
+fi
#!/bin/bash
-# --- retrieve APPLI path, relative to $HOME
-# on sarge, "which" gives not allways the absolute path...
-
-comName=`which $0`
-aa=${comName:0:1}
-if test x$aa == x\/; then
- mycom=${comName}
-elif test x$aa == x\.; then
- mycom=${PWD}/${comName:2}
-else
- mycom=${PWD}/${comName}
-fi
-APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
-#echo $APPLI
-export APPLI
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
# --- define port for CORBA naming service
-searchFreePort() {
- echo -n "Searching for a free port for naming service: "
- export NSPORT=2810
- local limit=$NSPORT
- let limit=limit+100
- while [ 1 ]
- do
- aRes=`netstat -ltn | grep -E :${NSPORT}`
- if [ -z "$aRes" ]; then
- echo ${NSPORT} - Ok
- local myhost=`hostname`
- export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
- export NSPORT
- export NSHOST=${myhost}
- local initref="NameService=corbaname::"`hostname`":$NSPORT"
- #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
- echo "InitRef = $initref" > $OMNIORB_CONFIG
- export LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
- rm ${LAST_RUNNING_CONFIG}
- ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
- break
- fi
- echo -n "${NSPORT} "
- if [[ $NSPORT -eq $limit ]] ; then
- echo
- echo "Can't find a free port to launch omniNames"
- echo "Try to kill the running servers and then launch SALOME again."
- exit
- fi
- let NSPORT=NSPORT+1
- done
-}
+. `dirname $0`/searchFreePort.sh
+searchFreePort
# --- if mpi lam, start lam (seems safe to be done several times)
# arret manuel avec lamhalt
# (default arguments defined in local salome.launch could be completed
# by arguments to this command)
-searchFreePort
-
if [ $# -ne 0 ] ; then
${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $*
- # --- todo delete omniORB config files in relation to the naming service kill
- rm ${OMNIORB_CONFIG}
- rm ${LAST_RUNNING_CONFIG}
+
else
${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py
fi
#!/bin/bash
-# --- retrieve APPLI path, relative to $HOME
-# on sarge, "which" gives not allways the absolute path...
-
-comName=`which $0`
-aa=${comName:0:1}
-if test x$aa == x\/; then
- mycom=${comName}
-elif test x$aa == x\.; then
- mycom=${PWD}/${comName:2}
-else
- mycom=${PWD}/${comName}
-fi
-APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
-#echo $APPLI
-export APPLI
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
#!/bin/bash
-./runAppli --killall
+./KillCurrentPort
+
+./runAppli --logger
-#./runSession killSalome.py
# $3 and following : local command to execute, with args
#
-# --- retrieve APPLI path, relative to $HOME
-# on sarge, "which" gives not allways the absolute path...
-
-comName=`which $0`
-aa=${comName:0:1}
-if test x$aa == x\/; then
- mycom=${comName}
-elif test x$aa == x\.; then
- mycom=${PWD}/${comName:2}
-else
- mycom=${PWD}/${comName}
-fi
-APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
-#echo $APPLI
-export APPLI
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
# Use it without args to run an interactive shell under Salome env
#
-# --- retrieve APPLI path, relative to $HOME
-# on sarge, "which" gives not allways the absolute path...
-
-comName=`which $0`
-aa=${comName:0:1}
-if test x$aa == x\/; then
- mycom=${comName}
-elif test x$aa == x\.; then
- mycom=${PWD}/${comName:2}
-else
- mycom=${PWD}/${comName}
-fi
-APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
-echo $APPLI
-export APPLI
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
. ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
+# --- set omniORB configuration to current session if any
+
myhost=`hostname`
-export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+fileOmniConfig=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+
+if [ -f $fileOmniConfig ]; then
+ export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+
+ # --- set environment variables for port and hostname of NamingService
+
+ export NSHOST=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py host`
+ export NSPORT=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port`
+fi
# --- invoque shell with or without args
#!/bin/bash
-# --- retrieve APPLI path, relative to $HOME
-# on sarge, "which" gives not allways the absolute path...
-
-comName=`which $0`
-aa=${comName:0:1}
-if test x$aa == x\/; then
- mycom=${comName}
-elif test x$aa == x\.; then
- mycom=${PWD}/${comName:2}
-else
- mycom=${PWD}/${comName}
-fi
-APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
-#echo $APPLI
-export APPLI
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+
+. `dirname $0`/setAppliPath.sh
# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
--- /dev/null
+#!/bin/bash
+
+# --- define port for CORBA naming service
+
+searchFreePort() {
+ echo -n "Searching for a free port for naming service: "
+ export NSPORT=2810
+ local limit=$NSPORT
+ let limit=limit+100
+ while [ 1 ]
+ do
+ aRes=`netstat -ltn | grep -E :${NSPORT}`
+ if [ -z "$aRes" ]; then
+ echo ${NSPORT} - Ok
+ local myhost=`hostname`
+ export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
+ export NSPORT
+ export NSHOST=${myhost}
+ local initref="NameService=corbaname::"`hostname`":$NSPORT"
+ #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
+ echo "InitRef = $initref" > $OMNIORB_CONFIG
+ export LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+ rm ${LAST_RUNNING_CONFIG}
+ ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
+ break
+ fi
+ echo -n "${NSPORT} "
+ if [[ $NSPORT -eq $limit ]] ; then
+ echo
+ echo "Can't find a free port to launch omniNames"
+ echo "Try to kill the running servers and then launch SALOME again."
+ exit
+ fi
+ let NSPORT=NSPORT+1
+ done
+}
+
--- /dev/null
+#!/bin/bash
+
+# --- retrieve APPLI path, relative to $HOME, set ${APPLI}
+# on sarge, "which" gives not allways the absolute path...
+
+comName=`which $0`
+aa=${comName:0:1}
+if test x$aa == x\/; then
+ mycom=${comName}
+elif test x$aa == x\.; then
+ mycom=${PWD}/${comName:2}
+else
+ mycom=${PWD}/${comName}
+fi
+APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
+#echo $APPLI
+export APPLI