Salome HOME
Modifying source command behavior as requested by CEA in 18/03/2016 meeting. The...
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 20 Apr 2016 07:59:33 +0000 (09:59 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 20 Apr 2016 07:59:33 +0000 (09:59 +0200)
commands/clean.py
commands/source.py
data/products/PRODUCT_GIT.pyconf
src/__init__.py
src/product.py

index 4484cb0656f5dd56c98958eb16da04a8c78eff82..f3570a036e899afe31b55ce26a87acc6e5379251 100644 (file)
@@ -149,7 +149,7 @@ def run(args, runner, logger):
     l_dir_to_suppress = []
     if options.all:
         l_dir_to_suppress += (get_source_directories(products_infos, 
-                                                options.sources_without_dev) +
+                                            options.sources_without_dev) +
                              get_build_directories(products_infos) + 
                              get_install_directories(products_infos))
     else:
index c13335be6b93cdd9df8cab419138803ba006f55d..b452900bc4a552eb0545e41dbfafe8cd150bd311 100644 (file)
@@ -27,10 +27,8 @@ parser = src.options.Options()
 parser.add_option('p', 'product', 'list2', 'products',
     _('products from which to get the sources. This option can be'
     ' passed several time to get the sources of several products.'))
-parser.add_option('f', 'force', 'boolean', 'force', 
-    _("force to remove the sources before getting them (in development mode only)."))
 
-def get_source_for_dev(config, product_info, source_dir, force, logger, pad):
+def get_source_for_dev(config, product_info, source_dir, logger, pad):
     '''The method called if the product is in development mode
     
     :param config Config: The global configuration
@@ -38,34 +36,23 @@ def get_source_for_dev(config, product_info, source_dir, force, logger, pad):
                                the product to be prepared
     :param source_dir Path: The Path instance corresponding to the 
                             directory where to put the sources
-    :param force boolean: True if the --force option was invoked
     :param logger Logger: The logger instance to use for the display and logging
     :param pad int: The gap to apply for the terminal display
     :return: True if it succeed, else False
     :rtype: boolean
     '''
-    retcode = 'N\A'
-    # if the product source directory does not exist,
-    # get it in checkout mode, else, do not do anything
-    # unless the force option is invoked
-    if not os.path.exists(product_info.source_dir) or force:
-        # If the source path exists (it means that force option is invoked)
-        # remove the source path
-        if source_dir.exists():
-            source_dir.rm()
-            
-        # Call the function corresponding to get the sources with True checkout
-        retcode = get_product_sources(config, 
-                                     product_info, 
-                                     True, 
-                                     source_dir,
-                                     force, 
-                                     logger, 
-                                     pad, 
-                                     checkout=True)
-        logger.write("\n", 3, False)
-        # +2 because product name is followed by ': '
-        logger.write(" " * (pad+2), 3, False) 
+       
+    # Call the function corresponding to get the sources with True checkout
+    retcode = get_product_sources(config, 
+                                 product_info, 
+                                 True, 
+                                 source_dir,
+                                 logger, 
+                                 pad, 
+                                 checkout=True)
+    logger.write("\n", 3, False)
+    # +2 because product name is followed by ': '
+    logger.write(" " * (pad+2), 3, False) 
     
     logger.write('dev: %s ... ' % 
                  src.printcolors.printcInfo(product_info.source_dir), 3, False)
@@ -248,7 +235,6 @@ def get_product_sources(config,
                        product_info, 
                        is_dev, 
                        source_dir,
-                       force,
                        logger, 
                        pad, 
                        checkout=False):
@@ -260,7 +246,6 @@ def get_product_sources(config,
     :param is_dev boolean: True if the product is in development mode
     :param source_dir Path: The Path instance corresponding to the 
                             directory where to put the sources
-    :param force boolean: True if the --force option was invoked
     :param logger Logger: The logger instance to use for the display and logging
     :param pad int: The gap to apply for the terminal display
     :param checkout boolean: If True, get the source in checkout mode
@@ -271,7 +256,6 @@ def get_product_sources(config,
         return get_source_for_dev(config, 
                                    product_info, 
                                    source_dir, 
-                                   force, 
                                    logger, 
                                    pad)
 
@@ -299,12 +283,22 @@ def get_product_sources(config,
 
     if product_info.get_source == "native":
         # skip
-        logger.write('%s ...' % _("native (ignored)"), 3, False)
+        logger.write('%s  ' % src.printcolors.printc(src.OK_STATUS),
+                     3,
+                     False)
+        msg = _('INFORMATION : Not doing anything because the product'
+                ' is of type "native".\n')
+        logger.write(msg, 3)
         return True        
 
     if product_info.get_source == "fixed":
         # skip
-        logger.write('%s ...' % _("fixed (ignored)"), 3, False)
+        logger.write('%s  ' % src.printcolors.printc(src.OK_STATUS),
+                     3,
+                     False)
+        msg = _('INFORMATION : Not doing anything because the product'
+                ' is of type "fixed".\n')
+        logger.write(msg, 3)
         return True  
 
     # if the get_source is not in [git, archive, cvs, svn, fixed, native]
@@ -314,12 +308,11 @@ def get_product_sources(config,
     logger.flush()
     return False
 
-def get_all_product_sources(config, products, force, logger):
+def get_all_product_sources(config, products, logger):
     '''Get all the product sources.
     
     :param config Config: The global configuration
     :param products List: The list of tuples (product name, product informations)
-    :param force boolean: True if the --force option was invoked
     :param logger Logger: The logger instance to be used for the logging
     :return: the tuple (number of success, dictionary product_name/success_fail)
     :rtype: (int,dict)
@@ -352,17 +345,22 @@ def get_all_product_sources(config, products, force, logger):
         # Remove the existing source directory if 
         # the product is not in development mode
         is_dev = src.product.product_is_dev(product_info)
-        if source_dir.exists() and not is_dev:
-            logger.write("  " + _('remove %s') % source_dir, 4)
-            logger.write("\n  ", 4, False)
-            source_dir.rm()
+        if source_dir.exists():
+            logger.write('%s  ' % src.printcolors.printc(src.OK_STATUS),
+                         3,
+                         False)
+            msg = _("INFORMATION : Not doing anything because the source"
+                    " directory already exists.\n")
+            logger.write(msg, 3)
+            good_result = good_result + 1
+            # Do not get the sources and go to next product
+            continue
 
         # Call to the function that get the sources for one product
         retcode = get_product_sources(config, 
                                      product_info, 
                                      is_dev, 
                                      source_dir,
-                                     force, 
                                      logger, 
                                      max_product_name_len, 
                                      checkout=False)
@@ -391,7 +389,9 @@ def get_all_product_sources(config, products, force, logger):
             res = src.KO_STATUS
         
         # print the result
-        logger.write('%s\n' % src.printcolors.printc(res), 3, False)
+        if not(src.product.product_is_fixed(product_info) or 
+               src.product.product_is_native(product_info)):
+            logger.write('%s\n' % src.printcolors.printc(res), 3, False)
 
     return good_result, results
 
@@ -419,21 +419,13 @@ def run(args, runner, logger):
     src.printcolors.print_value(logger, 'workdir', 
                                 runner.cfg.APPLICATION.workdir, 2)
     logger.write("\n", 2, False)
-    
-    # Get the force option if it was passed
-    force = options.force
-    if force:
-        msg = _("Warning: the --force option has effect only "
-                "on products in development mode\n\n")
-        logger.write(src.printcolors.printcWarning(msg))
-    
+       
     # Get the products list with products informations regarding the options
     products_infos = prepare.get_products_list(options, runner.cfg, logger)
     
     # Call to the function that gets all the sources
     good_result, results = get_all_product_sources(runner.cfg, 
                                                   products_infos,
-                                                  force,
                                                   logger)
 
     # Display the results (how much passed, how much failed, etc...)
index 4637aba3335ab15592769fb0ae2dbb2a05fcf035..34dbdc2609569669c414bbab9d6371c51a60819d 100644 (file)
@@ -20,5 +20,6 @@ PRODUCT_GIT :
     type : "sample"
     source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+    install_dir : "base"
     patches : []
 }
\ No newline at end of file
index 237ccc3a87225730add9fd5d2829cd4eb8961569..8e68a1ceb3dcadf8d46f06b6fef2b4d3d3e50a49 100644 (file)
@@ -76,6 +76,21 @@ def print_info(logger, info):
         printcolors.print_value(logger, sp + i[0], i[1], 2)
     logger.write("\n", 2)
 
+def get_base_path(config):
+    '''Returns the path of the product base.
+    
+    :param config Config: The global Config instance.
+    :return: The path of the product base.
+    :rtype: str
+    '''
+    if "base" in config.APPLICATION:
+        base_name = config.APPLICATION.base
+        base_path = config.USER.bases[base_name]
+    else:
+        # default base
+        base_path = config.USER.bases.base
+    return base_path
+
 ##
 # Utils class to simplify path manipulations.
 class Path:
index a5c5fb17fb72bf370eda4197386e36b083291a2f..de0e1d3a4f59c7276337bca4fae7a9ca2d68b49c 100644 (file)
@@ -111,7 +111,7 @@ def get_product_config(config, product_name):
             raise src.SatException(msg)
 
     # If there is no definition but the product is declared as native,
-    # construct a new defifnition containing only the get_source key
+    # construct a new definition containing only the get_source key
     if prod_info is None and version == "native":
         prod_info = src.pyconf.Config()
         prod_info.name = product_name
@@ -128,6 +128,12 @@ def get_product_config(config, product_name):
         prod_info.install_dir = os.path.join(config.APPLICATION.workdir,
                                             "INSTALL",
                                             prod_info.name)
+    else:
+        if prod_info.install_dir == "base":
+            # Get the product base of the application
+            base_path = src.get_base_path(config) 
+            prod_info.install_dir = os.path.join(base_path,
+                                            prod_info.name)
        
     return prod_info