Salome HOME
fix little bug about profile
[tools/sat.git] / src / __init__.py
index de1969cc4663261223d0a4be298b0eabfdd841b9..7a4ac04af6224aa37a7cfb13a3d6c320e771ba2d 100644 (file)
@@ -32,10 +32,15 @@ from . import product
 from . import environment
 from . import fileEnviron
 from . import compilation
+from . import test_module
 
 OK_STATUS = "OK"
 KO_STATUS = "KO"
 NA_STATUS = "NA"
+KNOWNFAILURE_STATUS = "KF"
+TIMEOUT_STATUS = "TIMEOUT"
+
+CONFIG_FILENAME = "sat-config.pyconf"
 
 class SatException(Exception):
     '''rename Exception Class
@@ -121,6 +126,26 @@ def get_base_path(config):
         base_path = config.USER.base
     return base_path
 
+def get_salome_version(config):
+    if hasattr(config.APPLICATION, 'version_salome'):
+        Version = config.APPLICATION.version_salome
+    else:
+        KERNEL_info = product.get_product_config(config, "KERNEL")
+        VERSION = os.path.join(
+                            KERNEL_info.install_dir,
+                            "bin",
+                            "salome",
+                            "VERSION")
+        if not os.path.isfile(VERSION):
+            return None
+            
+        fVERSION = open(VERSION)
+        Version = fVERSION.readline()
+        fVERSION.close()
+        
+    VersionSalome = int(only_numbers(Version))    
+    return VersionSalome
+
 def only_numbers(str_num):
     return ''.join([nb for nb in str_num if nb in '0123456789'] or '0')
 
@@ -289,4 +314,31 @@ def deepcopy_list(input_list):
     res = []
     for elem in input_list:
         res.append(elem)
-    return res
\ No newline at end of file
+    return res
+
+def parse_date(date):
+    """Transform YYYYMMDD_hhmmss into YYYY-MM-DD hh:mm:ss.
+    
+    :param date str: The date to transform
+    :return: The date in the new format
+    :rtype: str
+    """
+    if len(date) != 15:
+        return date
+    res = "%s-%s-%s %s:%s:%s" % (date[0:4],
+                                 date[4:6],
+                                 date[6:8],
+                                 date[9:11],
+                                 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