]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Check over OMNIORB_USER_PATH.
authoraguerre <aguerre>
Wed, 30 Oct 2013 10:29:52 +0000 (10:29 +0000)
committeraguerre <aguerre>
Wed, 30 Oct 2013 10:29:52 +0000 (10:29 +0000)
Test configuration file existence.

bin/appliskel/salome
bin/runSalome.py
bin/salomeLauncherUtils.py

index 0f402bf7d6aa7482486b2e11e1dbee0151270fc2..d12155b337e79f9ba3c0a14eaf316e8de83e6ccd 100755 (executable)
@@ -17,14 +17,15 @@ def __initialize():
   os.environ['APPLI'] = appliPath # needed to convert .sh environment files
   os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath
 
-  # define folder to store omniorb config (initially in virtual application folder)
-  #omniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
-  omniorbUserPath = os.path.join(homePath, appliPath, "USERS")
-  os.environ['OMNIORB_USER_PATH'] = omniorbUserPath
-  if not os.path.exists(omniorbUserPath):
-    os.makedirs(omniorbUserPath)
-
   sys.path[:0] = [absoluteAppliPath+'/bin/salome']
+
+  # define folder to store omniorb config (initially in virtual application folder)
+  try:
+    from salomeLauncherUtils import setOmniOrbUserPath
+    setOmniOrbUserPath()
+  except Exception, e:
+    print e
+    sys.exit(1)
 # End of preliminary work
 
 def main(args):
@@ -36,21 +37,12 @@ def main(args):
     usage()
     sys.exit(0)
 
-
   from salomeLauncherUtils import getConfigFileNames
-  configFileNames, args = getConfigFileNames(args)
-
-  # WHY? Incorrect/Inexisting files are supposed to be ignored by SalomeRunner.
-  # Might simply need bug fix; please provide test case.
-  error=False
-  for aFile in configFileNames:
-    if not os.path.isfile(aFile):
-      print "ERROR: inexisting file: "+aFile
-      error=True
-  if error:
+  configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
+  if len(unexisting) > 0:
+    print "ERROR: unexisting configuration file(s): " + ', '.join(unexisting)
     sys.exit(1)
 
-
   # Create a SalomeRunner which parses configFileNames to initialize environment
   try:
     from salomeRunner import SalomeRunner, SalomeRunnerException
index 676489e1fc68a767c66392553c4696e409c8149a..e92309a7bd2794fbfba519f55be826032a85c945 100755 (executable)
@@ -32,7 +32,6 @@ import setenv
 from launchConfigureParser import verbose
 from server import process_id, Server
 import json
-from salomeLauncherUtils import formatScriptsAndArgs
 import subprocess
 
 # -----------------------------------------------------------------------------
@@ -677,7 +676,7 @@ def startSalome(args, modules_list, modules_root_dir):
             import readline
         except ImportError:
             pass
-    
+
     # siman session paramenters and checkout processing
     if simanStudyName(args):
         print '**********************************************'
@@ -698,7 +697,7 @@ def startSalome(args, modules_list, modules_root_dir):
             mySession = obj._narrow(SALOME.Session)
             mySession.emitMessage("simanCheckoutDone " + simanStudyName(args))
         print '**********************************************'
-        
+
     return clt
 
 # -----------------------------------------------------------------------------
@@ -779,6 +778,7 @@ def useSalome(args, modules_list, modules_root_dir):
                 if not args['gui'] or not args['session_gui']:
                     toimport = args['pyscript']
 
+        from salomeLauncherUtils import formatScriptsAndArgs
         command = formatScriptsAndArgs(toimport)
         if command:
             proc = subprocess.Popen(command, shell=True)
@@ -830,16 +830,13 @@ def no_main():
 def main():
     """Salome launch as a main application"""
 
-    ### TEMP >>> ###
-    if not os.getenv("OMNIORB_USER_PATH"):
-        homePath = os.path.realpath(os.path.expanduser('~'))
-        #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
-        defaultOmniorbUserPath = homePath
-        if os.getenv("APPLI"):
-            defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
-        os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
-        pass
-    ### <<< TEMP ###
+    # define folder to store omniorb config (initially in virtual application folder)
+    try:
+        from salomeLauncherUtils import setOmniOrbUserPath
+        setOmniOrbUserPath()
+    except Exception, e:
+        print e
+        sys.exit(1)
 
     from salome_utils import getHostName
     print "runSalome running on %s" % getHostName()
index 5a59bb1786fec27df3e592e0a0d0936b56f377ef..a3696dec65ca8db26a783a61657e4453f158d68c 100644 (file)
@@ -32,7 +32,7 @@ def __getConfigFileNamesDefault():
   return __listDirectory(envdDir)
 #
 
-def getConfigFileNames(args):
+def getConfigFileNames(args, checkExistence=False):
   # special case: configuration files are provided by user
   # Search for command-line argument(s) --config=file1,file2,..., filen
   # Search for command-line argument(s) --config=dir1,dir2,..., dirn
@@ -40,12 +40,13 @@ def getConfigFileNames(args):
   configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
 
   if len(configArgs) == 0:
-    return __getConfigFileNamesDefault(), args
+    return __getConfigFileNamesDefault(), args, []
 
   args = [ x for x in args if not x.startswith(configOptionPrefix) ]
   allLists = [ x.replace(configOptionPrefix, '') for x in configArgs ]
 
   configFileNames = []
+  unexisting = []
   for currentList in allLists:
     elements = currentList.split(',')
     for elt in elements:
@@ -53,9 +54,12 @@ def getConfigFileNames(args):
       if os.path.isdir(elt):
         configFileNames += __listDirectory(elt)
       else:
-        configFileNames += [elt]
+        if checkExistence and not os.path.isfile(elt):
+          unexisting += [elt]
+        else:
+          configFileNames += [elt]
 
-  return configFileNames, args
+  return configFileNames, args, unexisting
 #
 
 # Return an array of dictionaries {script_name: [list_of_its_args]}
@@ -114,3 +118,29 @@ def formatScriptsAndArgs(scriptArgs=[]):
     command = "; ".join(["%s"%x for x in commands])
     return command
 #
+
+# Ensure OMNIORB_USER_PATH is defined. This variable refers to a the folder in which
+# SALOME will write omniOrb configuration files.
+# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
+# an exception is raised if check fails. It allows users for choosing a specific folder.
+# Else the function sets OMNIORB_USER_PATH this way:
+# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+#   The function does not check USERS folder existence or wrute access. This folder
+#   must exist ; this is the case if SALOME virtual application has been create using
+#   appli_gen.py script.
+# - Else OMNIORB_USER_PATH is set to user home directory.
+def setOmniOrbUserPath():
+  omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+  if omniorbUserPath:
+    if not os.access(omniorbUserPath, os.W_OK):
+      raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
+    pass
+  else:
+    homePath = os.path.realpath(os.path.expanduser('~'))
+    #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
+    defaultOmniorbUserPath = homePath
+    if os.getenv("APPLI"):
+      defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+      pass
+    os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
+#