]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Improve the way to get the product definitions. Fix a bug of the log command
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 16 Mar 2016 09:05:34 +0000 (10:05 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 16 Mar 2016 09:05:34 +0000 (10:05 +0100)
commands/prepare.py
commands/source.py
salomeTools.py
src/product.py
test/log/launch_browser.py

index bbd189b1d8954cc7723c44a5195b2ba5b8779022..f46d4b0a2965d64e3d3fa8ab2490de3789f5383b 100644 (file)
@@ -137,27 +137,22 @@ def run(args, runner, logger):
                     _('\nApply the patches to the sources of the products\n'))
     logger.write(msg)
 
-    # Construct the option to pass to the patch command    
-    if ("dev_products" in runner.cfg.APPLICATION and 
-                                runner.cfg.APPLICATION.dev_products is not []):
-        
-        dev_products = runner.cfg.APPLICATION.dev_products
-        ldev_products = [p for p in products_infos if p[0] in dev_products]
+    # Construct the option to pass to the patch command
+    ldev_products = [p for p in products_infos if src.product.product_is_dev(p[1])]
+    if len(ldev_products) > 0:
+        msg = _("Ignoring the following products "
+                "in development mode\n")
+        logger.write(src.printcolors.printcWarning(msg), 1)
+        for i, (product_name, __) in enumerate(ldev_products):
+            args_product_opt.replace(',' + product_name, '')
+            end_text = ', '
+            if i+1 == len(ldev_products):
+                end_text = '\n'
+                
+            logger.write(product_name + end_text, 1)
         
-        if len(ldev_products) > 0:
-            msg = _("Ignoring the following products "
-                    "in development mode\n")
-            logger.write(src.printcolors.printcWarning(msg), 1)
-            for i, (product_name, __) in enumerate(ldev_products):
-                args_product_opt.replace(',' + product_name, '')
-                end_text = ', '
-                if i+1 == len(ldev_products):
-                    end_text = '\n'
-                    
-                logger.write(product_name + end_text, 1)
-            
-            msg = _("Use the --force_patch option to apply the patches anyway\n")
-            logger.write(src.printcolors.printcWarning(msg), 1)
+        msg = _("Use the --force_patch option to apply the patches anyway\n\n")
+        logger.write(src.printcolors.printcWarning(msg), 1)
             
     
     args_patch = args_appli + args_product_opt + args_sample
index be83c0c25a2d2a0b1f022a4b9001ac92f7534ae6..5e58afaf4aaebbba80befa461717a5339b76d5eb 100644 (file)
@@ -340,7 +340,8 @@ def get_all_product_sources(config, products, force, logger):
     for product_name, product_info in products:
         # get product name, product informations and the directory where to put
         # the sources
-        if not src.product.product_is_fixed(product_info):
+        if (not (src.product.product_is_fixed(product_info) or 
+                 src.product.product_is_native(product_info))):
             source_dir = src.Path(product_info.source_dir)
         else:
             source_dir = src.Path('')
@@ -352,8 +353,7 @@ def get_all_product_sources(config, products, force, logger):
         
         # Remove the existing source directory if 
         # the product is not in development mode
-        is_dev = ("dev_products" in config.APPLICATION and 
-                  product_name in config.APPLICATION.dev_products)
+        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)
index eba93ea9832af5e1a8266e0264fbb3c5f7b48c4e..ba6d39f53ac769dee254c0cf22948848a834061d 100755 (executable)
@@ -148,6 +148,7 @@ class Sat(object):
                 # Make sure the internationalization is available
                 gettext.install('salomeTools', os.path.join(satdir, 'src', 'i18n'))
                 
+                # Get the arguments in a list and remove the empty elements
                 argv = args.split(" ")
                 if argv != ['']:
                     while "" in argv: argv.remove("")
@@ -190,7 +191,7 @@ class Sat(object):
                     launchedCommand = ' '.join([self.cfg.VARS.salometoolsway +
                                                 os.path.sep +
                                                 'sat',
-                                                self.arguments.split(' ')[0]
+                                                __nameCmd__
                                                 args])
                     logger_command.end_write({"launchedCommand" : launchedCommand})
                 
index 7ae8d6dcbed943ae9cce8998b632673f527a7100..6ac6ee9d36c59dd7aa63b298608066cc61f9fbae 100644 (file)
@@ -23,17 +23,46 @@ import src
 
 AVAILABLE_VCS = ['git', 'svn', 'cvs']
 
-def get_product_config(config, product_name, version):
+def get_product_config(config, product_name):
     '''Get the specific configuration of a product from the global configuration
     
     :param config Config: The global configuration
     :param product_name str: The name of the product
-    :param version str: The version of the product
     :return: the specific configuration of the product
     :rtype: Config
     '''
+    
+    # Get the version of the product from the application definition
+    version = config.APPLICATION.products[product_name]
+    # if no version, then take the default one defined in the application
+    if isinstance(version, bool): 
+        version = config.APPLICATION.tag      
+    
+    # Define debug and dev modes
+    # Get the tag if a dictionary is given in APPLICATION.products for the
+    # current product 
+    debug = 'no'
+    dev = 'no'
+    if isinstance(version, src.pyconf.Mapping):
+        dic_version = version
+        # Get the version/tag
+        if not 'tag' in dic_version:
+            version = config.APPLICATION.tag
+        else:
+            version = dic_version.tag
+        
+        # Get the debug if any
+        if 'debug' in dic_version:
+            debug = dic_version.debug
+        
+        # Get the dev if any
+        if 'dev' in dic_version:
+            dev = dic_version.dev
+    
     vv = version
-    # substitute some character with _
+    # substitute some character with _ in order to get the correct definition
+    # in config.PRODUCTS. This is done because the pyconf tool does not handle
+    # the . and - characters 
     for c in ".-": vv = vv.replace(c, "_")
     full_product_name = product_name + '_' + vv
 
@@ -52,9 +81,6 @@ def get_product_config(config, product_name, version):
         for depend in prod_info.opt_depend:
             if depend in config.PRODUCTS:
                 prod_info.depend.append(depend,'')
-                
-    # Check if the product is defined as native in the application
-    pass # to be done
     
     # In case of a product get with a vcs, put the tag (equal to the version)
     if prod_info is not None and prod_info.get_source in AVAILABLE_VCS:
@@ -72,6 +98,28 @@ def get_product_config(config, product_name, version):
     if prod_info is not None and prod_info.get_source=="fixed":
         prod_info.install_dir = version
     
+    # Check if the product is defined as native in the application
+    if prod_info is not None:
+        if version == "native":
+            prod_info.get_source = "native"
+        elif prod_info.get_source == "native":
+            msg = _("The product %(prod)s has version %(ver)s but is declared"
+                    " as native in its definition" %
+                { 'prod': prod_info.name, 'ver': version})
+            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
+    if prod_info is None and version == "native":
+        prod_info = src.pyconf.Config()
+        prod_info.name = product_name
+        prod_info.get_source = "native"
+    
+    # Set the debug and dev keys
+    if prod_info is not None:
+        prod_info.debug = debug
+        prod_info.dev = dev
+        
     return prod_info
 
 def get_products_infos(lproducts, config):
@@ -85,15 +133,9 @@ def get_products_infos(lproducts, config):
     '''
     products_infos = []
     # Loop on product names
-    for prod in lproducts:
-        # Get the version of the product from the application definition
-        version_prod = config.APPLICATION.products[prod]
-        # if no version, then take the default one defined in the application
-        if isinstance(version_prod, bool): 
-            version_prod = config.APPLICATION.tag
-        
+    for prod in lproducts:       
         # Get the specific configuration of the product
-        prod_info = get_product_config(config, prod, version_prod)
+        prod_info = get_product_config(config, prod)
         if prod_info is not None:
             products_infos.append((prod, prod_info))
         else:
@@ -110,8 +152,8 @@ def product_is_sample(product_info):
     :return: True if the product has the sample type, else False
     :rtype: boolean
     '''
-    mtype = product_info.type
-    return mtype.lower() == 'sample'
+    ptype = product_info.type
+    return ptype.lower() == 'sample'
 
 def product_is_fixed(product_info):
     '''Know if a product is fixed
@@ -122,4 +164,37 @@ def product_is_fixed(product_info):
     :rtype: boolean
     '''
     get_src = product_info.get_source
-    return get_src.lower() == 'fixed'
\ No newline at end of file
+    return get_src.lower() == 'fixed'
+
+def product_is_native(product_info):
+    '''Know if a product is native
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is native, else False
+    :rtype: boolean
+    '''
+    get_src = product_info.get_source
+    return get_src.lower() == 'native'
+
+def product_is_dev(product_info):
+    '''Know if a product is in dev mode
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is in dev mode, else False
+    :rtype: boolean
+    '''
+    dev = product_info.dev
+    return dev.lower() == 'yes'
+
+def product_is_debug(product_info):
+    '''Know if a product is in debug mode
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is in debug mode, else False
+    :rtype: boolean
+    '''
+    debug = product_info.debug
+    return debug.lower() == 'yes'
\ No newline at end of file
index c0cf72c4d685b39da30a7da4e627b3d696f76bdf..793e433bb5c26159670767dab29a05005608a52a 100644 (file)
@@ -56,7 +56,7 @@ class TestLog(unittest.TestCase):
         time.sleep(sleep_time)
 
         browser = sat.cfg.USER.browser
-        pid = check_proc_existence_and_kill(browser + ".*" + "xml")
+        pid = check_proc_existence_and_kill(browser + ".*" + "hat\.xml")
 
         if pid:
             OK = "OK"
@@ -330,14 +330,13 @@ class TestLog(unittest.TestCase):
 
         sat = Sat("-oUSER.browser='konqueror'")
         time.sleep(sleep_time)
-        time.sleep(5)
         cmd_log = threading.Thread(target=sat.log, args=('--full',))
         cmd_log.start()
 
         time.sleep(sleep_time)
 
         browser = sat.cfg.USER.browser
-        check_proc_existence_and_kill(browser + ".*" + "xml")
+        check_proc_existence_and_kill(browser + ".*" + "hat\.xml")
         
         # Read and check the hat.xml file contains at least one log file corresponding to log
         hatFilePath = os.path.join(sat.cfg.SITE.log.log_dir, "hat.xml")