]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: these modifications are mainly for the salome virtual application
authorcaremoli <caremoli>
Thu, 8 Jan 2009 17:28:49 +0000 (17:28 +0000)
committercaremoli <caremoli>
Thu, 8 Jan 2009 17:28:49 +0000 (17:28 +0000)
They allow one salome virtual application to be used by several users with
different logins. That was not possible before.
shutdownSalome has been modified to correctly handle salome virtual application
and to do same job from GUI or from console

15 files changed:
bin/appli_clean.sh
bin/appli_gen.py
bin/appliskel/killCurrentPort
bin/appliskel/runRemote.sh
bin/appliskel/runSession
bin/appliskel/runTests
bin/appliskel/searchFreePort.sh
bin/killSalomeWithPort.py
bin/runSalome.py
bin/salomeConsole.py
bin/salome_session.py
bin/salome_utils.py
bin/virtual_salome.py
bin/waitNS.sh
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx

index 9ea7ae8a729079664dd9a5476cd2eee9e62926c9..a5413a73733df5d6d79c1f54bd42ec891de9da91 100644 (file)
@@ -22,4 +22,4 @@
 #
 #clean appli
 #
-rm -rf bin lib share doc idl env.d envd getAppliPath.py searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc
+rm -rf bin lib share doc idl env.d envd USERS getAppliPath.py searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc
index 4fa0e2dcf543e9ba73d0f7be7d92c9523eaf750d..c57f4c25df1705c6d0a6c256737d22de3cf1f615 100644 (file)
 usage="""usage: %prog [options]
 Typical use is:
   python appli_gen.py 
-Use with options:
-  python appli_gen.py --prefix=<install directory> --config=<configuration file>
+Typical use with options is:
+  python appli_gen.py --verbose --prefix=<install directory> --config=<configuration file>
 """
 
 import os, glob, string, sys, re
+import shutil
 import xml.sax
 import optparse
 import virtual_salome
@@ -130,7 +131,16 @@ class params:
 
 # -----------------------------------------------------------------------------
 
-def install(prefix,config_file):
+def makedirs(namedir):
+  if os.path.exists(namedir):
+    dirbak=namedir+".bak"
+    if os.path.exists(dirbak):
+      shutil.rmtree(dirbak)
+    os.rename(namedir,dirbak)
+    os.listdir(dirbak) #sert seulement a mettre a jour le systeme de fichier sur certaines machines
+  os.makedirs(namedir)
+
+def install(prefix,config_file,verbose=0):
     home_dir=os.path.abspath(os.path.expanduser(prefix))
     filename=os.path.abspath(os.path.expanduser(config_file))
     _config={}
@@ -149,14 +159,15 @@ def install(prefix,config_file):
         print "Configure parser: Error : can not read configuration file %s, check existence and rights" % filename
         pass
 
-    for cle in _config.keys():
-        print cle, _config[cle]
-        pass
+    if verbose:
+        for cle in _config.keys():
+            print cle, _config[cle]
+            pass
 
     for module in _config["modules"]:
         print "--- add module ", module, _config[module]
         options = params()
-        options.verbose=0
+        options.verbose=verbose
         options.clear=0
         options.prefix=home_dir
         options.module=_config[module]
@@ -259,6 +270,11 @@ def install(prefix,config_file):
     f.write(command)    
     f.close()
 
+    #Add USERS directory with 777 permission to store users configuration files
+    users_dir=os.path.join(home_dir,'USERS')
+    makedirs(users_dir)
+    os.chmod(users_dir, 0777)
+
 def main():
     parser = optparse.OptionParser(usage=usage)
 
@@ -268,8 +284,11 @@ def main():
     parser.add_option('--config', dest="config", default='config_appli.xml',
                       help="XML configuration file (default config_appli.xml)")
 
+    parser.add_option('-v', '--verbose', action='count', dest='verbose',
+                      default=0, help="Increase verbosity")
+
     options, args = parser.parse_args()
-    install(prefix=options.prefix,config_file=options.config)
+    install(prefix=options.prefix,config_file=options.config,verbose=options.verbose)
     pass
 
 # -----------------------------------------------------------------------------
index d02c7f28b028a1449d0933949b6de1800c0a2f04..86a3f499a94921e5a1b9e206188def3c27c701f7 100755 (executable)
@@ -32,10 +32,10 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py`
 
 # --- find omniORB configuration relative to current session if any
 
-fileOmniConfig=${HOME}/${APPLI}/.omniORB_last.cfg
+fileOmniConfig=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
 
 if [ -f $fileOmniConfig ]; then
-  OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_last.cfg
+  OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
   export OMNIORB_CONFIG
 fi
 
index 5a50a1e4650c00983365e4cd224a38c9d47d2891..dd5258e4fe2ffb3598d9106404acff2933c22503 100755 (executable)
@@ -50,7 +50,7 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py`
 
 # --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
 
-OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_$1_$2.cfg
+OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_$1_$2.cfg
 export OMNIORB_CONFIG
 NSHOST=$1
 export NSHOST
index 5a14c9461ce23c5d795829df60f0d3a905738dca..716fbe6d9d843a29eb0a8c7d3063ba5df3eab608 100755 (executable)
@@ -36,20 +36,32 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py`
 
 . ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
 
-# --- set omniORB configuration to current session if any
+if test "x$1" == "xNSPORT"; then
+  NSPORT=$2
+  export NSPORT
+  myhost=`hostname`
+  OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_${NSPORT}.cfg
+  export OMNIORB_CONFIG
+  NSHOST=${myhost}
+  export NSHOST
+  shift 2
+else
 
-fileOmniConfig=${HOME}/${APPLI}/.omniORB_last.cfg
+  # --- set omniORB configuration to current session if any
 
-if [ -f $fileOmniConfig ]; then
-  OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_last.cfg
-  export OMNIORB_CONFIG
+  fileOmniConfig=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
 
-  # --- set environment variables for port and hostname of NamingService
+  if [ -f $fileOmniConfig ]; then
+    OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
+    export OMNIORB_CONFIG
 
-  NSHOST=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py host`
-  export NSHOST
-  NSPORT=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port`
-  export NSPORT
+    # --- set environment variables for port and hostname of NamingService
+
+    NSHOST=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py host`
+    export NSHOST
+    NSPORT=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port`
+    export NSPORT
+  fi
 fi
 
 # --- invoke shell with or without args
index a13b1a171cf04356df0beaf3be6a70c9f257a56d..2d9d9d42d462c83ed8af7027676eaa112f4e3666 100755 (executable)
@@ -43,7 +43,7 @@ searchFreePort() {
         if [ -z "$aRes" ]; then
             echo ${NSPORT} - Ok
            local myhost=`hostname`
-            OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
+            OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_${NSPORT}.cfg
             export OMNIORB_CONFIG
            export NSPORT
             NSHOST=${myhost}
@@ -51,7 +51,7 @@ searchFreePort() {
             local initref="NameService=corbaname::"`hostname`":$NSPORT"
             #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
             echo "InitRef = $initref" > $OMNIORB_CONFIG
-            LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_test.cfg
+            LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_test.cfg
             export LAST_RUNNING_CONFIG
            rm ${LAST_RUNNING_CONFIG}
             ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
index 33fc3bea996275240fb1294dbffafdabb72cc18c..ad8af9f3db87ea2a1ae25317994aedc0ef9c7429 100755 (executable)
@@ -34,7 +34,7 @@ searchFreePort() {
         if [ -z "$aRes" ]; then
             echo ${NSPORT} - Ok
            local myhost=`hostname`
-            OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
+            OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_${NSPORT}.cfg
             export OMNIORB_CONFIG
            export NSPORT
             NSHOST=${myhost}
@@ -42,7 +42,7 @@ searchFreePort() {
             local initref="NameService=corbaname::"`hostname`":$NSPORT"
             #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
             echo "InitRef = $initref" > $OMNIORB_CONFIG
-            LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_last.cfg
+            LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
             export LAST_RUNNING_CONFIG
            rm ${LAST_RUNNING_CONFIG}
             ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
index 2933cf267ca3f8714057287b06c17b58cc2ea66a..4403a8bc2687442826ec7f35b46e6fbbf27d5880 100755 (executable)
 #
 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-import os, sys, pickle, signal, commands
+import os, sys, pickle, signal, commands,glob
 from launchConfigureParser import verbose
+import Utils_Identity
+import salome_utils
 
 def getPiDict(port,appname='salome',full=True,hidden=True):
     """
@@ -65,8 +67,8 @@ def getPiDict(port,appname='salome',full=True,hidden=True):
 def appliCleanOmniOrbConfig(port):
     """
     Remove omniorb config files related to the port in SALOME application:
-    - ${HOME}/${APPLI}/.omniORB_${HOSTNAME}_${NSPORT}.cfg
-    - ${HOME}/${APPLI}/.omniORB_last.cfg
+    - ${HOME}/${APPLI}/USERS/.omniORB_${USER}_${HOSTNAME}_${NSPORT}.cfg
+    - ${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg
     the last is removed only if the link points to the first file.
     """
     from salome_utils import generateFileName
@@ -76,13 +78,15 @@ def appliCleanOmniOrbConfig(port):
         #Run outside application context
         pass
     else:
-        dir = os.path.join(home, appli)
+        dir = os.path.join(home, appli,"USERS")
         omniorb_config      = generateFileName(dir, prefix="omniORB",
                                                extension="cfg",
                                                hidden=True,
+                                               with_username=True,
                                                with_hostname=True,
                                                with_port=port)
         last_running_config = generateFileName(dir, prefix="omniORB",
+                                               with_username=True,
                                                suffix="last",
                                                extension="cfg",
                                                hidden=True)
@@ -97,6 +101,20 @@ def appliCleanOmniOrbConfig(port):
         if os.access(omniorb_config,os.F_OK):
             os.remove(omniorb_config)
             pass
+
+        #try to relink last.cfg to an existing config file if any
+        files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),
+                                       "USERS",".omniORB_"+salome_utils.getUserName()+"_*.cfg"))
+        current_config=None
+        current=0
+        for f in files:
+          stat=os.stat(f)
+          if stat.st_atime > current:
+            current=stat.st_atime
+            current_config=f
+        if current_config:
+          os.symlink(os.path.normpath(current_config), last_running_config)
+
         pass
     pass
 
@@ -190,6 +208,29 @@ def killMyPort(port):
     appliCleanOmniOrbConfig(port)
     pass
             
+def killNotifdAndClean(port):
+    """
+    Kill notifd daemon and clean application running on the specified port.
+    Parameters:
+    - port - port number
+    """
+    try:
+      filedict=getPiDict(port)
+      f=open(filedict, 'r')
+      pids=pickle.load(f)
+      for d in pids:
+        for pid,process in d.items():
+          if 'notifd' in process:
+            cmd='kill -9 %d'% pid
+            os.system(cmd)
+      os.remove(filedict)
+    except:
+      #import traceback
+      #traceback.print_exc()
+      pass
+
+    appliCleanOmniOrbConfig(port)
+    
 if __name__ == "__main__":
     for port in sys.argv[1:]:
         killMyPort(port)
index 3508a6cc8fcbb986b12345cb56871f17e4ee4834..c0c1ad1b75d2a4733b060648f9eca6ec6e6d98da 100755 (executable)
@@ -771,13 +771,17 @@ def searchFreePort(args, save_config=1):
             #
             home  = os.getenv("HOME")
             appli = os.getenv("APPLI")
-            if appli is not None: home = os.path.join(home, appli)
+            kwargs={}
+            if appli is not None: 
+              home = os.path.join(home, appli,"USERS")
+              kwargs["with_username"]=True
             #
             omniorb_config = generateFileName(home, prefix="omniORB",
                                               extension="cfg",
                                               hidden=True,
                                               with_hostname=True,
-                                              with_port=NSPORT)
+                                              with_port=NSPORT,
+                                              **kwargs)
             orbdata = []
             initref = "NameService=corbaname::%s:%s"%(hostname, NSPORT)
             import CORBA
@@ -804,7 +808,8 @@ def searchFreePort(args, save_config=1):
                 last_running_config = generateFileName(home, prefix="omniORB",
                                                        suffix="last",
                                                        extension="cfg",
-                                                       hidden=True)
+                                                       hidden=True,
+                                                       **kwargs)
                 try:
                     if sys.platform == "win32":
                         import shutil       
index d7916fe97989b730b1f739178d46a9e970c528be..56c805c14dee56954ca79e4db51d9f59a4218e96 100755 (executable)
@@ -44,13 +44,15 @@ import SALOME_ModuleCatalog
 reload(Engines)
 reload(SALOME)
 reload(SALOMEDS)
+import salome_utils
 
 import LifeCycleCORBA
 import orbmodule
 from runSalome import *
 
 import Utils_Identity
-files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),".omni*.cfg"))
+files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),
+                               "USERS",".omniORB_"+salome_utils.getUserName()+"_*.cfg"))
 
 filename=""
 if len(files)==1:
index 6a5d2f82bb71f733e25b7fe8826b85d0daac02da..9c648214dd6c7972154960850164d22ce519d345 100644 (file)
@@ -60,12 +60,16 @@ def searchFreePort():
         if status:
             home  = os.getenv("HOME")
             appli = os.getenv("APPLI")
-            if appli is not None: home = os.path.join(home, appli)
+            kwargs={}
+            if appli is not None: 
+              home = os.path.join(home, appli,"USERS")
+              kwargs["with_username"]=True
             omniorb_config = generateFileName(home, prefix="omniORB",
                                               extension="cfg",
                                               hidden=True,
                                               with_hostname=True,
-                                              with_port=NSPORT)
+                                              with_port=NSPORT,
+                                              **kwargs)
             f = open(omniorb_config, "w")
             f.write("ORBInitRef NameService=corbaname::%s:%s\n"%(hostname, NSPORT))
             f.close()
@@ -73,7 +77,8 @@ def searchFreePort():
             last_running_config = generateFileName(home, prefix="omniORB",
                                                    suffix="last",
                                                    extension="cfg",
-                                                   hidden=True)
+                                                   hidden=True,
+                                                   **kwargs)
             os.environ['LAST_RUNNING_CONFIG'] = last_running_config
             if os.access(last_running_config,os.F_OK):
                 os.unlink(last_running_config)
index 6d18fed9f00a4fcb73b537315e99f5be52dd5d90..ab9c0669cce28e74af10ba2be14f93ced6d54c14 100644 (file)
@@ -344,4 +344,4 @@ def generateFileName( dir, prefix = None, suffix = None, extension = None,
             name = os.path.join( dir, name )
             pass
         pass
-    return name
+    return os.path.normpath(name)
index b7f0e6708fe3cbda0c2fdfec308ad8209ee85652..971ab8c39dd8454d0e92603b3d0f7b73d503f79f 100644 (file)
@@ -40,7 +40,8 @@ verbose=0
 def mkdir(path):
     """Create a directory and all the intermediate directories if path does not exist"""
     if not os.path.exists(path):
-        print 'Creating %s' % path
+        if verbose:
+            print 'Creating %s' % path
         os.makedirs(path)
     else:
         if verbose:
@@ -58,7 +59,8 @@ def symlink(src, dest):
             pass
         os.symlink(src, dest)
     else:
-        print 'Symlink %s already exists' % dest
+        if verbose:
+            print 'Symlink %s already exists' % dest
         pass
     pass
 
@@ -89,6 +91,7 @@ def get_lib_dir():
 # -----------------------------------------------------------------------------
 
 def link_module(options):
+    global verbose
 
     if not options.module:
         print "Option module is mandatory"
@@ -99,6 +102,8 @@ def link_module(options):
         print "Module %s does not exist" % module_dir
         return
 
+    verbose = options.verbose
+
     home_dir = os.path.expanduser(options.prefix)
     #try to find python version of salome application and put it in versio
     pys=[os.path.split(s)[1] for s in glob.glob(os.path.join(home_dir,get_lib_dir(),"python*.*"))]
@@ -148,8 +153,6 @@ def link_module(options):
     sharedoc_gui_dir=os.path.join(home_dir,'share','doc','salome','gui')
     sharedoc_tui_dir=os.path.join(home_dir,'share','doc','salome','tui')
 
-    verbose = options.verbose
-
     if options.clear:
         rmtree(bin_dir)
         rmtree(idl_dir)
@@ -168,7 +171,8 @@ def link_module(options):
             pass
         pass
     else:
-        print module_bin_dir, " doesn't exist"
+        if verbose:
+            print module_bin_dir, " doesn't exist"
         pass    
     
     #directory idl/salome : create it and link content
@@ -177,7 +181,8 @@ def link_module(options):
         for fn in os.listdir(module_idl_dir):
             symlink(os.path.join(module_idl_dir, fn), os.path.join(idl_dir, fn))
     else:
-        print module_idl_dir, " doesn't exist"
+        if verbose:
+            print module_idl_dir, " doesn't exist"
 
     #directory lib/salome : create it and link content
     if os.path.exists(module_lib_dir):
@@ -187,7 +192,8 @@ def link_module(options):
             pass
         pass
     else:
-        print module_lib_dir, " doesn't exist"
+        if verbose:
+            print module_lib_dir, " doesn't exist"
         pass    
     
     #directory lib/pyversio/site-packages/salome : create it and link content
@@ -205,7 +211,8 @@ def link_module(options):
                 pass
             pass
         else:
-            print module_lib_py_shared_dir, " doesn't exist"
+            if verbose:
+                print module_lib_py_shared_dir, " doesn't exist"
             pass    
 
     #directory share/doc/salome (KERNEL doc) : create it and link content
index 2727217cf2eb85a184e405935e0e9f79872201f7..249f17d180eb1ba58d45848cdd28cc9ab61d3ac0 100755 (executable)
@@ -22,7 +22,7 @@
 #
 status=1
 while [ $status -ne 0 ]; do
-  ls $HOME/$APPLI/.omniORB_last.cfg >& /dev/null
+  ls $HOME/$APPLI/USERS/.omniORB_${USER}_last.cfg >& /dev/null
   status=$?
   sleep 1
   echo -n "#"
index 70f920c7c2f24095d0a88ca75fc00211d7a40c8b..e6e5936e76fe3ef36c45a13c509aa9439193f020 100644 (file)
@@ -541,16 +541,8 @@ void SALOME_LifeCycleCORBA::killOmniNames()
   // NPAL 18309  (Kill Notifd)
   if ( !portNumber.empty() ) 
     {
-      string cmd = ("import pickle, os; ");
-      cmd += string("from killSalomeWithPort import getPiDict; ");
-      cmd += string("filedict=getPiDict(") + portNumber + "); ";
-      cmd += string("f=open(filedict, 'r'); ");
-      cmd += string("pids=pickle.load(f); ");
-      cmd += string("m={}; ");
-      cmd += string("[ m.update(i) for i in pids ]; ");
-      cmd += string("pids=filter(lambda a: 'notifd' in m[a], m.keys()); ");
-      cmd += string("[ os.system('kill -9 %d'%pid) for pid in pids ]; ");
-      cmd += string("os.remove(filedict); ");
+      string cmd = ("from killSalomeWithPort import killNotifdAndClean; ");
+      cmd += string("killNotifdAndClean(") + portNumber + "); ";
       cmd  = string("python -c \"") + cmd +"\" >& /dev/null";
       MESSAGE(cmd);
       system( cmd.c_str() );