Salome HOME
sat prepare and sat install with pip, triggered by pip properties
[tools/sat.git] / src / __init__.py
index e24085b207a950b248de18793aba7e9bfa0ed5a9..ad0997b4f816e1c0aa5ecc563f02250cc5bd816c 100644 (file)
@@ -91,6 +91,27 @@ def check_config_has_profile( config, details = None ):
             details.append(message)
         raise SatException( message )
 
+def appli_test_property(config,property_name, property_value):
+    """Generic function to test if an application has a property set to a value
+    :param config class 'common.pyconf.Config': The config.
+    :param property_name : The name of the property to check
+    :param property_value : The value of the property to test
+    :return: True if the application has the property set to property_value
+    :rtype: boolean
+    """
+    # first check if application has property_value
+    if not ("APPLICATION"  in config and
+            "properties"   in config.APPLICATION and
+            property_name  in config.APPLICATION.properties):
+        return False
+
+    # then check to the property is set to property_value
+    eval_expression = 'config.APPLICATION.properties.%s == "%s"' %\
+                      (property_name,property_value)
+    result = eval(eval_expression)
+    return result
+    
+
 def config_has_application( config ):
     return 'APPLICATION' in config
 
@@ -147,7 +168,7 @@ def getProductNames(cfg, wildcards, logger):
         if len(filtered) > 0:
           res.append(prod)
           ok = True
-          break
+          continue
       if not ok:
         notFound[wild] = None
     if len(res) == 0:
@@ -228,6 +249,15 @@ def get_log_path(config):
     
     return log_dir_path
 
+def get_salometool_version(config):
+   """Return the salomeTool version.
+
+   :param config Config: The global Config instance.
+   :return: the description of this version of sat in terms of tag and commit
+   """
+   return config.LOCAL.tag
+
+
 def get_salome_version(config):
     import versionMinorMajorPatch as VMMP
 
@@ -418,8 +448,21 @@ def find_file_in_ftppath(file_name, ftppath, installation_dir, logger):
     :param logger Logger: The logging instance to use for the prints.
     :rtype: str
     """
+
+    # make sure installation_dir exists
+    if not os.path.exists(installation_dir):
+        os.makedirs(installation_dir)
+
     destination=os.path.join(installation_dir, file_name)
-    for ftp_archive in ftppath:
+
+    # paths in ftppath may contain several paths separated by ":"
+    # we plit them, and push all paths in bigftppath
+    bigftppath=[]
+    for ipath in ftppath:
+        splpath=ipath.split(":")
+        bigftppath+=splpath
+        
+    for ftp_archive in bigftppath:
        try:
            # ftp_archive has the form ftp.xxx.yyy/dir1/dir2/...
            ftp_archive_split=ftp_archive.split("/")