Salome HOME
jobs report, display error when jobs are missing somewhere in the week
[tools/sat.git] / src / __init__.py
index d397783137594c97258f81b7bde0a299cc567c30..fb5316936c1d56348647adfde5c5f649821eef05 100644 (file)
@@ -33,6 +33,7 @@ from . import environment
 from . import fileEnviron
 from . import compilation
 from . import test_module
+from . import template
 
 OK_STATUS = "OK"
 KO_STATUS = "KO"
@@ -40,6 +41,8 @@ NA_STATUS = "NA"
 KNOWNFAILURE_STATUS = "KF"
 TIMEOUT_STATUS = "TIMEOUT"
 
+CONFIG_FILENAME = "sat-config.pyconf"
+
 class SatException(Exception):
     '''rename Exception Class
     '''
@@ -117,12 +120,14 @@ def get_base_path(config):
     :return: The path of the product base.
     :rtype: str
     '''
-    if "base" in config.SITE:
-        base_path = config.SITE.base
-    else:
-        # default base
-        base_path = config.USER.base
-    return base_path
+    if "base" not in config.SITE:
+        site_file_path = os.path.join(config.VARS.salometoolsway,
+                                      "data",
+                                      "site.pyconf")
+        msg = _("Please define a base path in the file %s" % site_file_path)
+        raise SatException(msg)
+
+    return config.SITE.base
 
 def get_salome_version(config):
     if hasattr(config.APPLICATION, 'version_salome'):
@@ -188,6 +193,9 @@ class Path:
     def isdir(self):
         return os.path.isdir(self.path)
 
+    def isfile(self):
+        return os.path.isfile(self.path)
+
     def list(self):
         return [Path(p) for p in os.listdir(self.path)]
 
@@ -340,3 +348,14 @@ def merge_dicts(*dict_args):
     for dictionary in dict_args:
         result.update(dictionary)
     return result
+
+def replace_in_file(filein, strin, strout):
+    '''Replace <strin> by <strout> in file <filein>
+    '''
+    shutil.move(filein, filein + "_old")
+    fileout= filein
+    filein = filein + "_old"
+    fin = open(filein, "r")
+    fout = open(fileout, "w")
+    for line in fin:
+        fout.write(line.replace(strin, strout))
\ No newline at end of file