]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
'sat source' : add the testing of files after getting the sources
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 20 Apr 2016 09:16:56 +0000 (11:16 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 20 Apr 2016 09:16:56 +0000 (11:16 +0200)
commands/source.py
data/products/PRODUCT_ARCHIVE.pyconf

index b452900bc4a552eb0545e41dbfafe8cd150bd311..9e086e8c705d60fe800b6849a204089072f7a41d 100644 (file)
@@ -370,18 +370,23 @@ def get_all_product_sources(config, products, logger):
             if product_info.no_rpath:
                 hack_no_rpath(config, product_info, logger)
         '''
+        
+        # Check that the sources are correctly get using the files to be tested
+        # in product information
+        if retcode:
+            check_OK, wrong_path = check_sources(product_info, logger)
+            if not check_OK:
+                # Print the missing file path
+                msg = _("The required file %s does not exists. " % wrong_path)
+                logger.write(src.printcolors.printcError("\nERROR: ") + msg, 3)
+                retcode = False
 
         # show results
         results[product_name] = retcode
-        if retcode == 'N\A':
-            # The case where the product was not prepared because it is 
-            # in development mode
-            res =(src.printcolors.printc(src.OK_STATUS) + 
-                    src.printcolors.printcWarning(_(
-                                    ' source directory already exists')))
-            good_result = good_result + 1
-        elif retcode:
+        if retcode:
             # The case where it succeed
+            
+            
             res = src.OK_STATUS
             good_result = good_result + 1
         else:
@@ -395,6 +400,30 @@ def get_all_product_sources(config, products, logger):
 
     return good_result, results
 
+def check_sources(product_info, logger):
+    '''Check that the sources are correctly get, using the files to be tested
+       in product information
+    
+    :param product_info Config: The configuration specific to 
+                                the product to be prepared
+    :return: True if the files exists (or no files to test is provided).
+    :rtype: boolean
+    '''
+    # Get the files to test if there is any
+    if ("present_files" in product_info and 
+        "source" in product_info.present_files):
+        l_files_to_be_tested = product_info.present_files.source
+        for file_path in l_files_to_be_tested:
+            # The path to test is the source directory 
+            # of the product joined the file path provided
+            path_to_test = os.path.join(product_info.source_dir, file_path)
+            logger.write(_("\nTesting existence of file: \n"), 5)
+            logger.write(path_to_test, 5)
+            if not os.path.exists(path_to_test):
+                return False, path_to_test
+            logger.write(src.printcolors.printcSuccess(" OK\n"), 5)
+    return True, ""
+
 def description():
     '''method that is called when salomeTools is called with --help option.
     
index 079dede8a662edadaa8efe7a6812e03185b05201..bbda9f17977dd0fb0643bf35dcf60f808fd289f2 100644 (file)
@@ -38,6 +38,11 @@ PRODUCT_ARCHIVE_4_4_2 :
             "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
             "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
     }
+       present_files :
+       {
+          source : ['my_test_file.txt', 'my_test_file.txt~']
+          install : ['', '', '']
+       }
     depend : []
     opt_depend : []
     type : "sample"