]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Be able to produce a relative environment for a package launcher
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 3 Aug 2016 07:16:09 +0000 (09:16 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 3 Aug 2016 07:16:09 +0000 (09:16 +0200)
commands/launcher.py
src/__init__.py
src/environment.py
src/logger.py
src/product.py
src/xsl/jobs_board_report.xsl

index c706a3a2f6d5171083e9224efc23c807f76b6e13..537aecbabaf0df364eca0df3de68ed307272893c 100644 (file)
@@ -96,7 +96,7 @@ def generate_launch_file(config,
         # Write the launcher file\r
         logger.write(_("Generating launcher for %s :\n") % \r
                      src.printcolors.printcLabel(config.VARS.application), 1)\r
-        logger.write("  %s\n" %src.printcolors.printcLabel(filepath), 1)\r
+        logger.write("  %s\n" % src.printcolors.printcLabel(filepath), 1)\r
     \r
     # open the file and write into it\r
     launch_file = open(filepath, "w")\r
index f4c065d6aa6316a22fa5520d4854cbd839367b9d..d397783137594c97258f81b7bde0a299cc567c30 100644 (file)
@@ -330,3 +330,13 @@ def parse_date(date):
                                  date[11:13],
                                  date[13:])
     return res
+
+def merge_dicts(*dict_args):
+    '''
+    Given any number of dicts, shallow copy and merge into a new dict,
+    precedence goes to key value pairs in latter dicts.
+    '''
+    result = {}
+    for dictionary in dict_args:
+        result.update(dictionary)
+    return result
index 721fbeeabfeda1f49e937a42ff4f2f86f4a2aac6..668191a0fb2a7f4e4b5774f7083742df191279bb 100644 (file)
@@ -167,7 +167,7 @@ class SalomeEnviron:
     """Class to manage the environment of SALOME.
     """
 
-    def __init__(self, cfg, environ, forBuild=False):
+    def __init__(self, cfg, environ, forBuild=False, for_package=None):
         '''Initialization.
 
         :param cfg Config: the global config
@@ -175,10 +175,13 @@ class SalomeEnviron:
                                 to store the environment variables
         :param forBuild bool: If true, it is a launch environment, 
                               else a build one
+        :param for_package str: If not None, produce a relative environment 
+                                designed for a package. 
         '''
         self.environ = environ
         self.cfg = cfg
         self.forBuild = forBuild
+        self.for_package = for_package
         self.silent = False
 
     def __repr__(self):
@@ -372,12 +375,13 @@ class SalomeEnviron:
             elif not self.silent:
                 logger.write("  " + _("No install_dir for product %s\n") %
                               product_info.name, 5)
-
-        # set source dir, unless no source dir
-        if not src.product.product_is_fixed(product_info):
-            src_dir = product_info.name + "_SRC_DIR"
-            if not self.is_defined(src_dir):
-                self.set(src_dir, product_info.source_dir)
+        
+        if not self.for_package:
+            # set source dir, unless no source dir
+            if not src.product.product_is_fixed(product_info):
+                src_dir = product_info.name + "_SRC_DIR"
+                if not self.is_defined(src_dir):
+                    self.set(src_dir, product_info.source_dir)
 
     def set_salome_generic_product_env(self, product):
         """Sets the generic environment for a SALOME product.
@@ -478,6 +482,9 @@ class SalomeEnviron:
         # Get the informations corresponding to the product
         pi = src.product.get_product_config(self.cfg, product)
         
+        if self.for_package:
+            pi.install_dir = os.path.join(self.for_package, pi.name)
+                    
         # Do not define environment if the product is native
         if src.product.product_is_native(pi):
             return
@@ -669,24 +676,32 @@ class FileEnvWriter:
 
         return env_file.name
    
-    def write_cfgForPy_file(self, filename, additional_env = {}):
+    def write_cfgForPy_file(self,
+                            filename,
+                            additional_env = {},
+                            for_package = None):
         """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(aFile.name), 3)
+                              src.printcolors.printcLabel(filename.name), 3)
 
         # create then env object
         tmp = src.fileEnviron.get_file_environ(filename, 
                                                "cfgForPy", 
                                                {})
         # environment for launch
-        env = SalomeEnviron(self.config, tmp, forBuild=False)
+        env = SalomeEnviron(self.config,
+                            tmp,
+                            forBuild=False,
+                            for_package=for_package)
         env.silent = self.silent
 
         if self.env_info is not None:
index 0b31fba8de827abe438003f6dfdd8b73451ae070..6aeb94b5f45779dc98e384eb4d09c5ab6a2c4c55 100644 (file)
@@ -164,6 +164,7 @@ class Logger(object):
         else:
             if self.default_level <= current_output_verbose_level and not self.silentSysStd:
                 sys.stdout.write(message)
+        self.flush()
 
     def error(self, message):
         '''Print an error.
index 211c0b648933204053f1310600c06a7f1d6ea298..0f68482f5b0bd4cb3b3e6e8925b7418fafa48f00 100644 (file)
@@ -15,7 +15,7 @@
 #  You should have received a copy of the GNU Lesser General Public
 #  License along with this library; if not, write to the Free Software
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-'''In this file are implemented the classes and methods 
+'''In this file are implemented the methods 
    relative to the product notion of salomeTools
 '''
 
@@ -77,11 +77,13 @@ def get_product_config(config, product_name):
         # If it exists, get the information of the product_version
         if "version_" + vv in config.PRODUCTS[product_name]:
             # returns specific information for the given version
-            prod_info = config.PRODUCTS[product_name]["version_" + vv]    
+            prod_info = config.PRODUCTS[product_name]["version_" + vv]
+            prod_info.section = "version_" + vv
         # Get the standard informations
         elif "default" in config.PRODUCTS[product_name]:
             # returns the generic information (given version not found)
             prod_info = config.PRODUCTS[product_name].default
+            prod_info.section = "default"
         
         # merge opt_depend in depend
         if prod_info is not None and 'opt_depend' in prod_info:
@@ -155,9 +157,9 @@ def get_product_config(config, product_name):
         else:
             if (os.path.basename(prod_info.archive_info.archive_name) == 
                                         prod_info.archive_info.archive_name):
-            
+                arch_name = prod_info.archive_info.archive_name
                 arch_path = src.find_file_in_lpath(
-                                            prod_info.archive_info.archive_name,
+                                            arch_name,
                                             config.PATHS.ARCHIVEPATH)
                 if not arch_path:
                     msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
@@ -217,7 +219,7 @@ def get_product_config(config, product_name):
                     prod_info.compil_script)
     
     # Get the full paths of all the patches
-    if "patches" in prod_info:
+    if product_has_patches(prod_info):
         patches = []
         for patch in prod_info.patches:
             patch_path = patch
@@ -236,7 +238,7 @@ def get_product_config(config, product_name):
         prod_info.patches = patches
 
     # Get the full paths of the environment scripts
-    if "environ" in prod_info and "env_script" in prod_info.environ:
+    if product_has_env_script(prod_info):
         env_script_path = prod_info.environ.env_script
         # If only a filename, then search for the environment script 
         # in the PRODUCTPATH/env_scripts
@@ -427,4 +429,24 @@ def product_has_script(product_info):
         # Native case
         return False
     build_src = product_info.build_source
-    return build_src.lower() == 'script'
\ No newline at end of file
+    return build_src.lower() == 'script'
+
+def product_has_env_script(product_info):
+    '''Know if a product has an environment script
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product it has an environment script, else False
+    :rtype: boolean
+    '''
+    return "environ" in product_info and "env_script" in product_info.environ
+
+def product_has_patches(product_info):
+    '''Know if a product has one or more patches
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product has one or more patches
+    :rtype: boolean
+    '''
+    return "patches" in product_info and len(product_info.patches) > 0
\ No newline at end of file
index 837c1fd16346f7122348e358e1b402743353fc87..0f8bef9a0a87e71a08a9af1ce922d5d2cac66817 100644 (file)
                                    <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
                                    <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
                                    <xsl:attribute name="class">OK2day</xsl:attribute>
-                                   j
+                                   job
                              </a>
                            </xsl:when>
                            <xsl:when test="contains(state/., 'Timeout')">