Salome HOME
add get_value method to Environ classes, to conform with the API of FileEnviron
[tools/sat.git] / commands / launcher.py
index 213845adf783988b3703e0582a525e5554fbd234..1f18f5b7aa4c6e63226e16c6126fbf7f8ce6f9c1 100644 (file)
@@ -24,6 +24,7 @@ import subprocess
 import stat
 
 import src
+import src.debug as DBG
 
 parser = src.options.Options()
 
@@ -36,6 +37,9 @@ parser.add_option('', 'gencat', 'string', 'gencat',
     _("Optional: Create a resources catalog for the specified machines "
       "(separated with ',') \n\tNOTICE: this command will ssh to retrieve"
       " information to each machine in the list"))
+parser.add_option('', 'use_mesa', 'boolean', 'use_mesa',
+    _("Optional: Create a launcher that will use mesa products\n\t"
+      "It can be usefull whan salome is used on a remote machine through ssh"))
 
 def generate_launch_file(config,
                          logger,
@@ -69,6 +73,7 @@ def generate_launch_file(config,
     additional_env['APPLI'] = filepath
 
 
+
     # get KERNEL bin installation path 
     # (in order for the launcher to get python salomeContext API)
     kernel_cfg = src.product.get_product_config(config, "KERNEL")
@@ -82,13 +87,34 @@ def generate_launch_file(config,
     else:
         bin_kernel_install_dir = os.path.join(kernel_root_dir,"bin","salome") 
 
-    # Get the launcher template
-    withProfile = src.fileEnviron.withProfile\
-                     .replace("BIN_KERNEL_INSTALL_DIR", bin_kernel_install_dir)\
-                     .replace("KERNEL_INSTALL_DIR", kernel_root_dir)
+    # check if the application contains an application module
+    l_product_info = src.product.get_products_infos(config.APPLICATION.products.keys(),
+                                                    config)
+    salome_application_name="Not defined" 
+    for prod_name, prod_info in l_product_info:
+        # look for a salome application
+        if src.get_property_in_product_cfg(prod_info, "is_salome_application") == "yes":
+            salome_application_name=prod_info.install_dir
+            continue
+
+    # if the application contains an application module, we set ABSOLUTE_APPLI_PATH to it.
+    # if not we set it to KERNEL_INSTALL_DIR, which is sufficient, except for salome test
+    if salome_application_name == "Not defined":
+        app_root_dir=kernel_root_dir
+    else:
+        app_root_dir=salome_application_name
 
-    before, after = withProfile.split(
-                                "# here your local standalone environment\n")
+    # Get the launcher template (python3 or python2)
+    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)
+    else:
+        withProfile = src.fileEnviron.withProfile\
+                         .replace("BIN_KERNEL_INSTALL_DIR", bin_kernel_install_dir)\
+                         .replace("KERNEL_INSTALL_DIR", app_root_dir)
+
+    before, after = withProfile.split("# here your local standalone environment\n")
 
     # create an environment file writer
     writer = src.environment.FileEnvWriter(config,
@@ -256,6 +282,10 @@ def run(args, runner, logger):
                                          logger)
         additional_environ = copy_catalog(runner.cfg, catalog_path)
 
+    # activate mesa use in the generated launcher
+    if options.use_mesa:
+        src.activate_mesa_property(runner.cfg)
+
     # Generate the launcher
     launcherPath = generate_launch_file( runner.cfg,
                                          logger,