From 3326f1f9ca282cca567edc2946b02140e39446b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 11 Mar 2014 15:22:11 +0100 Subject: [PATCH] rename salome runner/launcher as salome context --- bin/CMakeLists.txt | 6 ++--- bin/appliskel/salome | 26 +++++++++---------- bin/launchConfigureParser.py | 2 +- bin/runSalome.py | 12 ++++----- bin/{salomeRunner.py => salomeContext.py} | 22 ++++++++-------- ...erUtils.py.in => salomeContextUtils.py.in} | 16 ++++++------ 6 files changed, 42 insertions(+), 42 deletions(-) rename bin/{salomeRunner.py => salomeContext.py} (95%) rename bin/{salomeLauncherUtils.py.in => salomeContextUtils.py.in} (94%) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 431f7f961..455fc61e1 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -20,7 +20,7 @@ ADD_SUBDIRECTORY(appliskel) SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS}) -SALOME_CONFIGURE_FILE(salomeLauncherUtils.py.in salomeLauncherUtils.py) +SALOME_CONFIGURE_FILE(salomeContextUtils.py.in salomeContextUtils.py) # =============================================================== # Files to be installed @@ -49,8 +49,8 @@ SET(SCRIPTS runSession.py runConsole.py salomeConsole.py - ${CMAKE_CURRENT_BINARY_DIR}/salomeLauncherUtils.py - salomeRunner.py + ${CMAKE_CURRENT_BINARY_DIR}/salomeContextUtils.py + salomeContext.py salome_session.py salome_utils.py searchFreePort.py diff --git a/bin/appliskel/salome b/bin/appliskel/salome index baeead6c4..e61b6cbab 100755 --- a/bin/appliskel/salome +++ b/bin/appliskel/salome @@ -40,7 +40,7 @@ def __initialize(): # define folder to store omniorb config (initially in virtual application folder) try: - from salomeLauncherUtils import setOmniOrbUserPath + from salomeContextUtils import setOmniOrbUserPath setOmniOrbUserPath() except Exception, e: print e @@ -52,32 +52,32 @@ def main(args): __initialize() if args == ['--help']: - from salomeRunner import usage + from salomeContext import usage usage() sys.exit(0) - from salomeLauncherUtils import getConfigFileNames + from salomeContextUtils import getConfigFileNames 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 + # Create a SalomeContext which parses configFileNames to initialize environment try: - from salomeRunner import SalomeRunner, SalomeRunnerException - runner = SalomeRunner(configFileNames) + from salomeContext import SalomeContext, SalomeContextException + context = SalomeContext(configFileNames) # Here set specific variables, if needed - # runner.addToPath('mypath') - # runner.addToLdLibraryPath('myldlibrarypath') - # runner.addToPythonPath('mypythonpath') - # runner.setEnviron('myvarname', 'value') + # context.addToPath('mypath') + # context.addToLdLibraryPath('myldlibrarypath') + # context.addToPythonPath('mypythonpath') + # context.setEnviron('myvarname', 'value') # Start SALOME, parsing command line arguments - runner.go(args) - print 'Thank you for using SALOME!' + context.go(args) + #print 'Thank you for using SALOME!' - except SalomeRunnerException, e: + except SalomeContextException, e: import logging logging.getLogger("salome").error(e) sys.exit(1) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 2176d4e7f..cfb247f61 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -28,7 +28,7 @@ import types from salome_utils import verbose, setVerbose, getPortNumber, getHomeDir -from salomeLauncherUtils import getScriptsAndArgs +from salomeContextUtils import getScriptsAndArgs # names of tags in XML configuration file doc_tag = "document" diff --git a/bin/runSalome.py b/bin/runSalome.py index df7b7b0c6..514bd07fc 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -764,7 +764,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 + from salomeContextUtils import formatScriptsAndArgs command = formatScriptsAndArgs(toimport) if command: proc = subprocess.Popen(command, shell=True) @@ -812,9 +812,9 @@ def no_main(): searchFreePort(args, 0) clt = useSalome(args, modules_list, modules_root_dir) - if args.has_key('shutdown_servers') : + if args.has_key('shutdown_servers') : var = args['shutdown_servers'] - if hasattr(var, 'delete') and callable(getattr(var, 'delete')) : + if hasattr(var, 'delete') and callable(getattr(var, 'delete')) : var.delete() return clt @@ -825,7 +825,7 @@ def main(): # define folder to store omniorb config (initially in virtual application folder) try: - from salomeLauncherUtils import setOmniOrbUserPath + from salomeContextUtils import setOmniOrbUserPath setOmniOrbUserPath() except Exception, e: print e @@ -944,9 +944,9 @@ def runSalome(): foreGround(clt, args) pass # -- - if args.has_key('shutdown_servers') : + if args.has_key('shutdown_servers') : var = args['shutdown_servers'] - if hasattr(var, 'delete') and callable(getattr(var, 'delete')) : + if hasattr(var, 'delete') and callable(getattr(var, 'delete')) : var.delete() pass # diff --git a/bin/salomeRunner.py b/bin/salomeContext.py similarity index 95% rename from bin/salomeRunner.py rename to bin/salomeContext.py index a12311c1f..d7d282c9d 100644 --- a/bin/salomeRunner.py +++ b/bin/salomeContext.py @@ -30,8 +30,8 @@ import pickle import subprocess import platform -from salomeLauncherUtils import SalomeRunnerException -from salomeLauncherUtils import getScriptsAndArgs, formatScriptsAndArgs +from salomeContextUtils import SalomeContextException +from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs def usage(): #exeName = os.path.splitext(os.path.basename(__file__))[0] @@ -56,17 +56,17 @@ to show help on start and shell commands. # """ -The SalomeRunner class in an API to configure SALOME environment then +The SalomeContext class in an API to configure SALOME environment then start SALOME using a single python command. """ -class SalomeRunner: +class SalomeContext: """ Initialize environment from a list of configuration files identified by their names. These files should be in appropriate (new .cfg) format. However you can give old .sh environment files; in this case, - the SalomeRunner class will try to automatically convert them + the SalomeContext class will try to automatically convert them to .cfg format before setting the environment. """ def __init__(self, configFileNames=[]): @@ -75,7 +75,7 @@ class SalomeRunner: return if len(configFileNames) == 0: - raise SalomeRunnerException("No configuration files given") + raise SalomeContextException("No configuration files given") reserved=['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH'] for filename in configFileNames: @@ -108,9 +108,9 @@ class SalomeRunner: if "--shutdown-server" in e: kill = True args.remove(e) - + absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','') - proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeRunner.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True) + proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeContext.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True) proc.communicate() if kill: self._killAll(args) @@ -224,7 +224,7 @@ class SalomeRunner: import traceback traceback.print_exc() sys.exit(1) - except SalomeRunnerException, e: + except SalomeContextException, e: self.getLogger().error(e) sys.exit(1) # @@ -388,9 +388,9 @@ class SalomeRunner: import pickle if __name__ == "__main__": if len(sys.argv) == 3: - runner = pickle.loads(sys.argv[1]) + context = pickle.loads(sys.argv[1]) args = pickle.loads(sys.argv[2]) - (out, err) = runner._getStarted(args) + (out, err) = context._getStarted(args) if out: sys.stdout.write(out) if err: diff --git a/bin/salomeLauncherUtils.py.in b/bin/salomeContextUtils.py.in similarity index 94% rename from bin/salomeLauncherUtils.py.in rename to bin/salomeContextUtils.py.in index 0b03c392f..a48e66848 100644 --- a/bin/salomeLauncherUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -26,10 +26,10 @@ import subprocess import re """ -Define a specific exception class to manage exceptions related to SalomeRunner +Define a specific exception class to manage exceptions related to SalomeContext """ -class SalomeRunnerException(Exception): - """Report error messages to the user interface of SalomeRunner.""" +class SalomeContextException(Exception): + """Report error messages to the user interface of SalomeContext.""" # def __listDirectory(path): @@ -96,7 +96,7 @@ def getScriptsAndArgs(args=[]): if elt.startswith(argsPrefix): if not currentKey or callPython: - raise SalomeRunnerException("args list must follow corresponding script file in command line.") + raise SalomeContextException("args list must follow corresponding script file in command line.") elt = elt.replace(argsPrefix, '') scriptArgs[len(scriptArgs)-1][currentKey] = elt.split(",") currentKey = None @@ -124,9 +124,9 @@ def getScriptsAndArgs(args=[]): ispython = False try: fn = open(currentScript) - for i in xrange(10): # read only 10 first lines + for i in xrange(10): # read only 10 first lines ln = fn.readline() - if re.search("#!.*python"): + if re.search("#!.*python"): ispython = True break pass @@ -153,8 +153,8 @@ def formatScriptsAndArgs(scriptArgs=[]): if sc_args: cmd = cmd + " " + " ".join(sc_args) commands.append(cmd) - sep = " ; " - if sys.platform == "win32": + sep = " ; " + if sys.platform == "win32": sep= " & " command = sep.join(["%s"%x for x in commands]) return command -- 2.30.2