Salome HOME
Restructuration des fonctions de gestion de l'environnement
authorcrouzet <nicolas.crouzet@cea.fr>
Mon, 29 Jul 2019 10:09:09 +0000 (12:09 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Mon, 29 Jul 2019 10:09:09 +0000 (12:09 +0200)
 - restructuration de LauncherFileEnviron, héritage de FileEnviron
 - Suppression de la fonction spécifique write_cfgForPy_file.
   (fonction write_cfg_file est maintanant utilisée pour tous gérer tous fichiers d'environnement générés)
 - sat package : suppression de l'option without_commercial  (obsolète)
 - environnement.finish : suppression argument required (inutile)
 - suppression  de de fonction run_simple_env_script (non utile)
 - suppression de PYTHON_LIBDIR1 (lib64) : obsolète et très consommateur de caractères dans PATHs

utilisationde finish pour gérer les ajouts en fin de fichier d'environnement (utile pour les
lanceurs python)

commands/launcher.py
commands/package.py
complete_sat.sh
src/environment.py
src/fileEnviron.py

index ec55a12aa7b9d8346bd668bab8aeff858fe07b8d..dccb9739157d6abfe295074ca0df12297dc5a2bd 100644 (file)
@@ -74,10 +74,6 @@ def generate_launch_file(config,
     if os.path.exists(filepath):
         os.remove(filepath)
 
-    # Add the APPLI variable
-    additional_env['APPLI'] = filepath
-
-
 
     # get KERNEL bin installation path 
     # (in order for the launcher to get python salomeContext API)
@@ -109,17 +105,17 @@ def generate_launch_file(config,
     else:
         app_root_dir=salome_application_name
 
-    # Get the launcher template (python3 or python2)
+    # Add two sat variables used by fileEnviron to choose the right launcher header 
+    # and do substitutions
+    additional_env['sat_bin_kernel_install_dir'] = bin_kernel_install_dir
     if "python3" in config.APPLICATION and config.APPLICATION.python3 == "yes":
-        withProfile = src.fileEnviron.withProfile3\
-                         .replace("BIN_KERNEL_INSTALL_DIR", bin_kernel_install_dir)\
-                         .replace("KERNEL_INSTALL_DIR", app_root_dir)
+        additional_env['sat_python_version'] = 3
     else:
-        withProfile = src.fileEnviron.withProfile\
-                         .replace("BIN_KERNEL_INSTALL_DIR", bin_kernel_install_dir)\
-                         .replace("KERNEL_INSTALL_DIR", app_root_dir)
+        additional_env['sat_python_version'] = 2
 
-    before, after = withProfile.split("# here your local standalone environment\n")
+    # Add the APPLI and ABSOLUTE_APPLI_PATH variable
+    additional_env['APPLI'] = filepath
+    additional_env['ABSOLUTE_APPLI_PATH'] = app_root_dir
 
     # create an environment file writer
     writer = src.environment.FileEnvWriter(config,
@@ -135,14 +131,12 @@ def generate_launch_file(config,
                      src.printcolors.printcLabel(config.VARS.application), 1)
         logger.write("  %s\n" % src.printcolors.printcLabel(filepath), 1)
     
-    # open the file and write into it
-    launch_file = open(filepath, "w")
-    launch_file.write(before)
-    # Write
-    writer.write_cfgForPy_file(launch_file, additional_env=additional_env,
-                               no_path_init=no_path_init)
-    launch_file.write(after)
-    launch_file.close()
+    # Write the launcher
+    writer.write_env_file(filepath, 
+                          False,  # for launch
+                          "cfgForPy",
+                          additional_env=additional_env,
+                          no_path_init=no_path_init)
     
     # change the rights in order to make the file executable for everybody
     os.chmod(filepath,
index c24de6ebc95ab0582f4fd8d119ae52bb5ef7f291..865979e3acb54998f84f7aa95ebd174182d71402 100644 (file)
@@ -108,8 +108,6 @@ parser.add_option('n', 'name', 'string', 'name',
     _('Optional: The name or full path of the archive.'), None)
 parser.add_option('', 'add_files', 'list2', 'add_files',
     _('Optional: The list of additional files to add to the archive.'), [])
-parser.add_option('', 'without_commercial', 'boolean', 'without_commercial',
-    _('Optional: do not add commercial licence.'), False)
 parser.add_option('', 'without_properties', 'properties', 'without_properties',
     _('Optional: Filter the products by their properties.\n\tSyntax: '
       '--without_properties <property>:<value>'))
@@ -177,8 +175,7 @@ def produce_relative_launcher(config,
                               logger,
                               file_dir,
                               file_name,
-                              binaries_dir_name,
-                              with_commercial=True):
+                              binaries_dir_name):
     '''Create a specific SALOME launcher for the binary package. This launcher 
        uses relative paths.
     
@@ -223,40 +220,35 @@ def produce_relative_launcher(config,
     else:
         app_root_dir=os.path.join(binaries_dir_name, salome_application_name)
 
-    # Get the launcher template and do substitutions
+    additional_env={}
+    additional_env['sat_bin_kernel_install_dir'] = "out_dir_Path + " +\
+                                                   config.VARS.sep + bin_kernel_install_dir
     if "python3" in config.APPLICATION and config.APPLICATION.python3 == "yes":
-        withProfile = src.fileEnviron.withProfile3
+        additional_env['sat_python_version'] = 3
     else:
-        withProfile = src.fileEnviron.withProfile
-
-    withProfile = withProfile.replace(
-        "ABSOLUTE_APPLI_PATH'] = 'KERNEL_INSTALL_DIR'",
-        "ABSOLUTE_APPLI_PATH'] = out_dir_Path + '" + config.VARS.sep + app_root_dir + "'")
-    withProfile = withProfile.replace(
-        " 'BIN_KERNEL_INSTALL_DIR'",
-        " out_dir_Path + '" + config.VARS.sep + bin_kernel_install_dir + "'")
+        additional_env['sat_python_version'] = 2
 
-    before, after = withProfile.split("# here your local standalone environment\n")
+    additional_env['ABSOLUTE_APPLI_PATH'] = "out_dir_Path" + config.VARS.sep + app_root_dir
 
     # create an environment file writer
     writer = src.environment.FileEnvWriter(config,
                                            logger,
                                            file_dir,
-                                           src_root=None)
+                                           src_root=None,
+                                           env_info=None)
     
     filepath = os.path.join(file_dir, file_name)
-    # open the file and write into it
-    launch_file = open(filepath, "w")
-    launch_file.write(before)
     # Write
-    writer.write_cfgForPy_file(launch_file,
-                               for_package = binaries_dir_name,
-                               with_commercial=with_commercial)
-    launch_file.write(after)
-    launch_file.close()
+    writer.write_env_file(filepath,
+                          False,  # for launch
+                          "cfgForPy",
+                          additional_env=additional_env,
+                          no_path_init="False",
+                          for_package = binaries_dir_name)
     
     # Little hack to put out_dir_Path outside the strings
     src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' )
+    src.replace_in_file(filepath, "'out_dir_Path + ", "out_dir_Path + '" )
     
     # A hack to put a call to a file for distene licence.
     # It does nothing to an application that has no distene product
@@ -274,6 +266,7 @@ def produce_relative_launcher(config,
              stat.S_IXGRP |
              stat.S_IXOTH)
 
+    print "CNC filepath = ", filepath
     return filepath
 
 def hack_for_distene_licence(filepath, licence_file):
@@ -634,8 +627,7 @@ WARNING: existing binaries directory from previous detar installation:
                                                  logger,
                                                  tmp_working_dir,
                                                  launcher_name,
-                                                 binaries_dir_name,
-                                                 not(options.without_commercial))
+                                                 binaries_dir_name)
             d_products["launcher"] = (launcher_package, launcher_name)
 
             # if the application contains mesa products, we generate in addition to the 
@@ -655,8 +647,7 @@ WARNING: existing binaries directory from previous detar installation:
                                                      logger,
                                                      tmp_working_dir,
                                                      launcher_mesa_name,
-                                                     binaries_dir_name,
-                                                     not(options.without_commercial))
+                                                     binaries_dir_name)
                 d_products["launcher (mesa)"] = (launcher_package_mesa, launcher_mesa_name)
 
                 # if there was a use_mesa value, we restore it
index 497e4ef18d427193a913714bf4bdcd0efa7da446..c1f55ca488509e9017dd3dca9a63a7f25afce272 100755 (executable)
@@ -237,7 +237,7 @@ _salomeTools_complete()
             return 0
             ;;
         package)
-            opts="--name --binaries --sources --project --salometools --force_creation --add_files --with_vcs --ftp --without_commercial --without_property"
+            opts="--name --binaries --sources --project --salometools --force_creation --add_files --with_vcs --ftp --without_property"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
index ae237f6c009ba3a2a29aa285c0b2b29a8072149b..81505bfc51788f927826f3012e477ea57420e5a0 100644 (file)
@@ -20,6 +20,7 @@ import os
 import subprocess
 import string
 import sys
+import copy
 
 import src
 import src.debug as DBG
@@ -324,7 +325,7 @@ class SalomeEnviron:
         if 'add_warning' in dir(self.environ):
             self.environ.add_warning(warning)
 
-    def finish(self, required):
+    def finish(self):
         """\
         Add a final instruction in the out file (in case of file generation)
         
@@ -334,20 +335,15 @@ class SalomeEnviron:
             self.environ.add_line(1)
             # what for ?
             # self.environ.add_comment("clean all the path")
-            self.environ.finish(required)
+            self.environ.finish()
 
     def set_python_libdirs(self):
         """Set some generic variables for python library paths"""
         ver = self.get('PYTHON_VERSION')
-        self.set('PYTHON_LIBDIR0', os.path.join('lib',
+        self.set('PYTHON_LIBDIR', os.path.join('lib',
                                                 'python' + ver,
                                                 'site-packages'))
-        self.set('PYTHON_LIBDIR1', os.path.join('lib64',
-                                                'python' + ver,
-                                                'site-packages'))
-          
-        self.python_lib0 = self.get('PYTHON_LIBDIR0')
-        self.python_lib1 = self.get('PYTHON_LIBDIR1')
+        self.python_lib = self.get('PYTHON_LIBDIR')
         self.has_python = True
 
     def get_names(self, lProducts):
@@ -467,15 +463,13 @@ class SalomeEnviron:
             bin_path = os.path.join(env_root_dir, 'bin')
             if self.has_python:
             # if the application doesn't include python, we don't need these two lines
-                pylib1_path = os.path.join(env_root_dir, self.python_lib0)
-                pylib2_path = os.path.join(env_root_dir, self.python_lib1)
+                pylib1_path = os.path.join(env_root_dir, self.python_lib)
         else:
             lib_path = os.path.join(env_root_dir, 'lib', 'salome')
             bin_path = os.path.join(env_root_dir, 'bin', 'salome')
             if self.has_python:
             # if the application doesn't include python, we don't need these two lines
-                pylib1_path = os.path.join(env_root_dir, self.python_lib0, 'salome')
-                pylib2_path = os.path.join(env_root_dir, self.python_lib1, 'salome')
+                pylib1_path = os.path.join(env_root_dir, self.python_lib, 'salome')
 
         # Construct the paths to prepend to PATH and LD_LIBRARY_PATH and 
         # PYTHONPATH
@@ -522,8 +516,7 @@ class SalomeEnviron:
 
             l = [ bin_path, lib_path ]
             if self.has_python:
-                l.append(os.path.join(env_root_dir, self.python_lib0))
-                l.append(os.path.join(env_root_dir, self.python_lib1))
+                l.append(os.path.join(env_root_dir, self.python_lib))
             self.prepend('PYTHONPATH', l)
 
     def load_cfg_environment(self, cfg_env):
@@ -726,40 +719,6 @@ class SalomeEnviron:
             traceback.print_tb(exceptionTraceback)
             traceback.print_exc()
 
-    def run_simple_env_script(self, script_path, logger=None):
-        """\
-        Runs an environment script. Same as run_env_script, but with a 
-        script path as parameter.
-        
-        :param script_path str: a path to an environment script
-        :param logger Logger: The logger instance to display messages
-        """
-        if not self.enable_simple_env_script:
-            return
-        # Check that the script exists
-        if not os.path.exists(script_path):
-            raise src.SatException(_("Environment script not found: %s") % 
-                                   script_path)
-
-        if not self.silent and logger is not None:
-            logger.write("  ** load %s\n" % script_path, 4)
-
-        script_basename = os.path.basename(script_path)
-        if script_basename.endswith(".py"):
-            script_basename = script_basename[:-len(".py")]
-
-        # import the script and run the set_env function
-        try:
-            import imp
-            pyproduct = imp.load_source(script_basename + "_env_script",
-                                        script_path)
-            pyproduct.load_env(self)
-        except:
-            __, exceptionValue, exceptionTraceback = sys.exc_info()
-            print(exceptionValue)
-            import traceback
-            traceback.print_tb(exceptionTraceback)
-            traceback.print_exc()
 
     def set_products(self, logger, src_root=None):
         """\
@@ -781,7 +740,6 @@ class SalomeEnviron:
             if product == "Python":
                 continue
             self.set_a_product(product, logger)
-            self.finish(False)
  
     def set_full_environ(self, logger, env_info):
         """\
@@ -828,13 +786,23 @@ class FileEnvWriter:
         self.silent = True
         self.env_info = env_info
 
-    def write_env_file(self, filename, forBuild, shell, for_package = None):
+    def write_env_file(self,
+                       filename,
+                       forBuild, 
+                       shell, 
+                       for_package = None,
+                       no_path_init=False,
+                       additional_env = {}):
         """\
         Create an environment file.
         
         :param filename str: the file path
         :param forBuild bool: if true, the build environment
         :param shell str: the type of file wanted (.sh, .bat)
+        :param for_package bool: if true do specific stuff for required for packages
+        :param no_path_init bool: if true generate a environ file that do not reinitialise paths
+        :param additional_env dict: contains sat_ prefixed variables to help the génération, 
+                                    and also variables to add in the environment.
         :return: The path to the generated file
         :rtype: str
         """
@@ -844,10 +812,23 @@ class FileEnvWriter:
 
         # create then env object
         env_file = open(os.path.join(self.out_dir, filename), "w")
-        tmp = src.fileEnviron.get_file_environ(env_file,
+
+        # we duplicate additional_env, and transmit it to fileEnviron, which will use its sat_ prefixed variables.
+        # the other variables of additional_env are added to the environement file at the end of this function.
+        salome_env = copy.deepcopy(additional_env)
+        file_environ = src.fileEnviron.get_file_environ(env_file,
                                                shell,
-                                               {})
-        env = SalomeEnviron(self.config, tmp, forBuild, for_package=for_package)
+                                               src.environment.Environ(salome_env))
+        if no_path_init:
+            # specify we don't want to reinitialise paths
+            # path will keep the inherited value, which will be appended with new values.
+            file_environ.set_no_init_path()
+
+        env = SalomeEnviron(self.config, 
+                            file_environ, 
+                            forBuild, 
+                            for_package=for_package)
+
         env.silent = self.silent
 
         # Set the environment
@@ -865,70 +846,22 @@ class FileEnvWriter:
             env.set_products(self.logger,
                             src_root=self.src_root)
 
-        # add cleanup and close
-        env.finish(True)
-        env_file.close()
-
-        return env_file.name
-   
-    def write_cfgForPy_file(self,
-                            filename,
-                            additional_env = {},
-                            for_package = None,
-                            with_commercial = True,
-                            no_path_init=False):
-        """\
-        Append to current opened aFile a cfgForPy 
-        environment (SALOME python launcher).
-           
-        :param filename str: the file path
-        :param additional_env dict: a dictionary of additional variables 
-                                    to add to the environment
-        :param for_package str: If not None, produce a relative environment 
-                                designed for a package. 
-        """
-        if not self.silent:
-            self.logger.write(_("Create configuration file %s\n") % 
-                              src.printcolors.printcLabel(filename.name), 3)
-
-        # create then env object
-        tmp = src.fileEnviron.get_file_environ(filename, "cfgForPy", {})
-        if no_path_init:
-            # specify we don't want to reinitialise paths
-            tmp.set_no_init_path()
-
-        # environment for launch
-        env = SalomeEnviron(self.config,
-                            tmp,
-                            forBuild=False,
-                            for_package=for_package,
-                            enable_simple_env_script = with_commercial)
-        env.silent = self.silent
-
-        DBG.write("write_cfgForPy_file", self.config.APPLICATION.environ)
-
-        if self.env_info is not None:
-            env.set_full_environ(self.logger, self.env_info)
-            DBG.write("set_full_environ", self.env_info)
-
-        else:
-            # set env from PRODUCT
-            env.set_application_env(self.logger)
-
-            # The list of products to launch
-            lProductsName = env.get_names(self.config.APPLICATION.products.keys())
-            env.set("SALOME_MODULES", ','.join(lProductsName))
-
-            # set the products
-            env.set_products(self.logger, src_root=self.src_root)
-
         # Add the additional environment if it is not empty
         if len(additional_env) != 0:
+            env.add_line(1)
+            env.add_comment("[APPLI variables]")
             for variable in additional_env:
-                env.set(variable, additional_env[variable])
+                if not variable.startswith("sat_"):
+                    # by convention variables starting with sat_ are used to transfer information, 
+                    # not to be written in env
+                    env.set(variable, additional_env[variable])
 
-        # add cleanup and close
-        env.finish(True)
+        # finalise the writing and close the file
+        env.finish()
+        env_file.close()
+
+        return env_file.name
+   
 
 class Shell:
     """\
@@ -955,4 +888,3 @@ def load_environment(config, build, logger):
     environ = SalomeEnviron(config, Environ(os.environ), build)
     environ.set_application_env(logger)
     environ.set_products(logger)
-    environ.finish(True)
index ba3d54a9515cc3c394eab7d858d460f38013ce3b..5b293ffcb8ed948cfae504ba6d6b3d1ccc9f3a83 100644 (file)
@@ -22,32 +22,6 @@ import src.debug as DBG
 import src.architecture
 import src.environment
 
-bat_header="""\
-@echo off
-
-rem The following variables are used only in case of a sat package
-set out_dir_Path=%~dp0
-"""
-
-
-bash_header="""\
-#!/bin/bash
-##########################################################################
-#
-# This line is used only in case of a sat package
-export out_dir_Path=$(cd $(dirname ${BASH_SOURCE[0]});pwd)
-
-###########################################################################
-"""
-
-cfg_header="""\
-[SALOME Configuration]
-"""
-
-Launcher_header="""\
-# a generated SALOME Configuration file using python syntax
-"""
-
 def get_file_environ(output, shell, environ=None):
     """Instantiate correct FileEnvironment sub-class.
     
@@ -55,14 +29,16 @@ def get_file_environ(output, shell, environ=None):
     :param shell str: the type of shell syntax to use.
     :param environ dict: a potential additional environment.
     """
+    if environ == None:
+        environ=src.environment.Environ({})
     if shell == "bash":
-        return BashFileEnviron(output, src.environment.Environ({}))
+        return BashFileEnviron(output, environ)
     if shell == "bat":
-        return BatFileEnviron(output, src.environment.Environ({}))
+        return BatFileEnviron(output, environ)
     if shell == "cfgForPy":
-        return LauncherFileEnviron(output, src.environment.Environ({}))
+        return LauncherFileEnviron(output, environ)
     if shell == "cfg":
-        return ContextFileEnviron(output, src.environment.Environ({}))
+        return ContextFileEnviron(output, environ)
     raise Exception("FileEnviron: Unknown shell = %s" % shell)
 
 class FileEnviron(object):
@@ -243,7 +219,7 @@ class FileEnviron(object):
         """
         return self.environ.get_value(key)
 
-    def finish(self, required):
+    def finish(self):
         """Add a final instruction in the out file (in case of file generation)
         
         :param required bool: Do nothing if required is False
@@ -327,14 +303,6 @@ class BatFileEnviron(FileEnviron):
         self.output.write('set %s=%s\n' % (key, self.value_filter(value)))
         self.environ.set(key, value)
 
-    def finish(self, required=True):
-        """\
-        Add a final instruction in the out file (in case of file generation)
-        In the particular windows case, do nothing
-        
-        :param required bool: Do nothing if required is False
-        """
-        return
 
 class ContextFileEnviron(FileEnviron):
     """Class for a salome context configuration file.
@@ -405,13 +373,6 @@ class ContextFileEnviron(FileEnviron):
         """
         self.prepend_value(key, value)
 
-    def finish(self, required=True):
-        """Add a final instruction in the out file (in case of file generation)
-        
-        :param required bool: Do nothing if required is False
-        """
-        return
-
 
 class LauncherFileEnviron(FileEnviron):
     """\
@@ -425,14 +386,25 @@ class LauncherFileEnviron(FileEnviron):
         :param environ dict: a potential additional environment.
         """
         self._do_init(output, environ)
+        self.python_version=self.environ.get("sat_python_version")
+        self.bin_kernel_root_dir=self.environ.get("sat_bin_kernel_install_dir")
+        self.app_root_dir=self.environ.get("sat_app_root_dir")
 
         # four whitespaces for first indentation in a python script
         self.indent="    "
         self.prefix="context."
         self.setVarEnv="setVariable"
-        
         self.begin=self.indent+self.prefix
-        self.output.write(Launcher_header)
+
+        # write the begining of launcher file.
+        # choose the template version corresponding to python version 
+        # and substitute BIN_KERNEL_INSTALL_DIR (the path to salomeContext.py)
+        if self.python_version == 2:
+            launcher_header=launcher_header2
+        else:
+            launcher_header=launcher_header3
+        self.output.write(launcher_header\
+                          .replace("BIN_KERNEL_INSTALL_DIR", self.bin_kernel_root_dir))
 
         # for these path, we use specialired functions in salomeContext api
         self.specialKeys={"PATH": "Path",
@@ -573,13 +545,18 @@ class LauncherFileEnviron(FileEnviron):
 
         self.output.write(self.indent+"# %s\n" % comment)
 
-    def finish(self, required=True):
+    def finish(self):
         """\
         Add a final instruction in the out file (in case of file generation)
         In the particular launcher case, do nothing
         
         :param required bool: Do nothing if required is False
         """
+        if self.python_version == 2:
+            launcher_tail=launcher_tail_py2
+        else:
+            launcher_tail=launcher_tail_py3
+        self.output.write(launcher_tail)
         return
 
 class ScreenEnviron(FileEnviron):
@@ -631,8 +608,33 @@ class ScreenEnviron(FileEnviron):
     def run_env_script(self, module, script):
         self.write("load", script, "", sign="")
 
-# The SALOME launcher template 
-withProfile =  """\
+
+#
+#  Headers
+#
+bat_header="""\
+@echo off
+
+rem The following variables are used only in case of a sat package
+set out_dir_Path=%~dp0
+"""
+
+
+bash_header="""\
+#!/bin/bash
+##########################################################################
+#
+# This line is used only in case of a sat package
+export out_dir_Path=$(cd $(dirname ${BASH_SOURCE[0]});pwd)
+
+###########################################################################
+"""
+
+cfg_header="""\
+[SALOME Configuration]
+"""
+
+launcher_header2="""\
 #! /usr/bin/env python
 
 ################################################################
@@ -652,8 +654,7 @@ out_dir_Path=os.path.dirname(os.path.realpath(__file__))
 # Preliminary work to initialize path to SALOME Python modules
 def __initialize():
 
-  sys.path[:0] = [ 'BIN_KERNEL_INSTALL_DIR' ]
-  os.environ['ABSOLUTE_APPLI_PATH'] = 'KERNEL_INSTALL_DIR'
+  sys.path[:0] = [ 'BIN_KERNEL_INSTALL_DIR' ]  # to get salomeContext
   
   # define folder to store omniorb config (initially in virtual application folder)
   try:
@@ -710,30 +711,9 @@ def main(args):
 
     # Logger level error
     context.getLogger().setLevel(40)
-
-    # here your local standalone environment
-
-    if len(args) >1 and args[0]=='doc':
-        _showDoc(args[1:])
-        return
-
-    # Start SALOME, parsing command line arguments
-    out, err, status = context.runSalome(args)
-    sys.exit(status)
-
-  except SalomeContextException, e:
-    import logging
-    logging.getLogger("salome").error(e)
-    sys.exit(1)
-#
-
-if __name__ == "__main__":
-  args = sys.argv[1:]
-  main(args)
-#
 """
-    
-withProfile3 =  """\
+
+launcher_header3="""\
 #! /usr/bin/env python3
 
 ################################################################
@@ -754,7 +734,6 @@ out_dir_Path=os.path.dirname(os.path.realpath(__file__))
 def __initialize():
 
   sys.path[:0] = [ 'BIN_KERNEL_INSTALL_DIR' ]
-  os.environ['ABSOLUTE_APPLI_PATH'] = 'KERNEL_INSTALL_DIR'
   
   # define folder to store omniorb config (initially in virtual application folder)
   try:
@@ -811,9 +790,30 @@ def main(args):
 
     # Logger level error
     context.getLogger().setLevel(40)
+"""
 
-    # here your local standalone environment
+launcher_tail_py2="""\
+    if len(args) >1 and args[0]=='doc':
+        _showDoc(args[1:])
+        return
+
+    # Start SALOME, parsing command line arguments
+    out, err, status = context.runSalome(args)
+    sys.exit(status)
 
+  except SalomeContextException, e:
+    import logging
+    logging.getLogger("salome").error(e)
+    sys.exit(1)
+#
+
+if __name__ == "__main__":
+  args = sys.argv[1:]
+  main(args)
+#
+"""
+
+launcher_tail_py3="""\
     if len(args) >1 and args[0]=='doc':
         _showDoc(args[1:])
         return
@@ -834,3 +834,4 @@ if __name__ == "__main__":
 #
 """
     
+