Test configuration file existence.
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):
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
from launchConfigureParser import verbose
from server import process_id, Server
import json
-from salomeLauncherUtils import formatScriptsAndArgs
import subprocess
# -----------------------------------------------------------------------------
import readline
except ImportError:
pass
-
+
# siman session paramenters and checkout processing
if simanStudyName(args):
print '**********************************************'
mySession = obj._narrow(SALOME.Session)
mySession.emitMessage("simanCheckoutDone " + simanStudyName(args))
print '**********************************************'
-
+
return clt
# -----------------------------------------------------------------------------
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)
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()
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
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:
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]}
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
+#