]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: Application scripts improvement
authorprascle <prascle>
Tue, 29 Nov 2005 18:22:51 +0000 (18:22 +0000)
committerprascle <prascle>
Tue, 29 Nov 2005 18:22:51 +0000 (18:22 +0000)
12 files changed:
Makefile.in
bin/NSparam.py [new file with mode: 0755]
bin/appliskel/README
bin/appliskel/killCurrentPort [new file with mode: 0755]
bin/appliskel/runAppli
bin/appliskel/runConsole
bin/appliskel/runParam
bin/appliskel/runRemote.sh
bin/appliskel/runSession
bin/appliskel/runTests
bin/appliskel/searchFreePort.sh [new file with mode: 0755]
bin/appliskel/setAppliPath.sh [new file with mode: 0755]

index 85ffaf0225aea74aa7e72c360c7b884addb4718f..42dedf9404d953d1a5de097ffaf94f8497024cf8 100644 (file)
@@ -41,7 +41,8 @@ salome.launch \
 envSalome.py \
 salomeConsole.py \
 showNS.py \
-addToKillList.py
+addToKillList.py \
+NSparam.py
 
 # copy header files in common directory
 OWN_CONFIG_H=@OWN_CONFIG_H@
diff --git a/bin/NSparam.py b/bin/NSparam.py
new file mode 100755 (executable)
index 0000000..721c6a0
--- /dev/null
@@ -0,0 +1,69 @@
+#!/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
index e54cc886b1f41fea35a96353f019b3f9d33c35e6..f3f283cb8810a1ace8a842401179cd59866096d2 100644 (file)
@@ -17,13 +17,13 @@ SALOME Application concept
 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
@@ -41,10 +41,15 @@ runConsole
    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
 ---------------------------
@@ -52,6 +57,12 @@ 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
@@ -59,6 +70,7 @@ 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
 ------------------------------------------------------------------------------
 
diff --git a/bin/appliskel/killCurrentPort b/bin/appliskel/killCurrentPort
new file mode 100755 (executable)
index 0000000..bca5060
--- /dev/null
@@ -0,0 +1,35 @@
+#!/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
index 700e669d4e5a1342548b7a24be3d469a049ae939..1d86ad3d596273903687f570c706a0a420a8bf37 100755 (executable)
@@ -1,20 +1,8 @@
 #!/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...)
 
@@ -22,38 +10,8 @@ export APPLI
 
 # --- 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
@@ -66,13 +24,9 @@ fi
 #    (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
index e45f586112c305e12d1da58421099a4e7dbe7252..caeabbdd61319e13363aaad5944a21d032d5e8a9 100755 (executable)
@@ -1,20 +1,8 @@
 #!/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...)
 
index 17bbd618b308b5f37b4c29f6edde6cbd37fae7e5..c858c670fcdea8da2a0c25c67fddc14dfae8a714 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
 
-./runAppli --killall  
+./KillCurrentPort
+
+./runAppli --logger  
 
-#./runSession killSalome.py
index d3297a6c5ce80e561dab308ffbef69694e56203c..594616a0709701485a25059c812642b114070f51 100755 (executable)
 #     $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...)
 
index 2ab579ce6d80091da99e6d26e688f40944089969..22d3fdd0fb3307419a4e8f9ff1e3ef810454d9f0 100755 (executable)
@@ -5,28 +5,27 @@
 # 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
 
index 6e625f0a0e82ecf4768f660c84c1ea1893e6fae9..755825d797a7588da6480fdbdbaa56faaec88d91 100755 (executable)
@@ -1,20 +1,8 @@
 #!/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...)
 
diff --git a/bin/appliskel/searchFreePort.sh b/bin/appliskel/searchFreePort.sh
new file mode 100755 (executable)
index 0000000..8108a93
--- /dev/null
@@ -0,0 +1,37 @@
+#!/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
+}
+
diff --git a/bin/appliskel/setAppliPath.sh b/bin/appliskel/setAppliPath.sh
new file mode 100755 (executable)
index 0000000..d9361ae
--- /dev/null
@@ -0,0 +1,17 @@
+#!/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