Salome HOME
sat #18501 bug fix : pour une archive, ecriture du pyconf de l'application directemen...
authorcrouzet <nicolas.crouzet@cea.fr>
Fri, 20 Dec 2019 13:43:44 +0000 (14:43 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Fri, 20 Dec 2019 13:43:44 +0000 (14:43 +0100)
on evite du coup tous les problemes lies aux overwrite (notamment les rm_products)

commands/config.py
commands/package.py

index ca3da051c2c6093d20fdc4d92f1a7537a667d21c..6be16dba9fb0617ab1c41d3c8a9bc5efb3f9181e 100644 (file)
@@ -527,6 +527,8 @@ class ConfigManager:
         if "APPLICATION" in cfg and "rm_products" in cfg.APPLICATION:
             for prod_to_remove in cfg.APPLICATION.rm_products:
                 cfg.APPLICATION.products.__delitem__(prod_to_remove)
+            # remove rm_products section after usage
+            cfg.APPLICATION.__delitem__("rm_products")
         return cfg
 
     def set_user_config_file(self, config):
@@ -1136,6 +1138,7 @@ def run(args, runner, logger):
     # case : give a synthetic view of all patches used in the application
     if options.show_properties:
         src.check_config_has_application(runner.cfg)
+
         # Print some informations
         logger.write(_('Properties of application %s\n') %
                     src.printcolors.printcLabel(runner.cfg.VARS.application), 3)
index 25cf410ab1b4c1bd573741ada6beb2cdfed8353b..a5b448fce18e6dc47120c0ea10f4ba99a1b01965 100644 (file)
@@ -1026,7 +1026,10 @@ def create_project_for_src_package(config, tmp_working_dir, with_vcs, with_ftp):
                                         patches_tmp_dir,
                                         products_pyconf_tmp_dir)
     
-    find_application_pyconf(config, application_tmp_dir)
+    # for the application pyconf, we write directly the config
+    # don't search for the original pyconf file
+    # to avoid problems with overwrite sections and rm_products key
+    write_application_pyconf(config, application_tmp_dir)
     
     d_project = {"project" : (project_tmp_dir, PROJECT_DIR )}
     return d_project
@@ -1110,43 +1113,34 @@ def find_product_scripts_and_pyconf(p_name,
     product_pyconf_cfg.__save__(ff, 1)
     ff.close()
 
-def find_application_pyconf(config, application_tmp_dir):
-    '''Find the application pyconf file and put it in the specific temporary 
+
+def write_application_pyconf(config, application_tmp_dir):
+    '''Write the application pyconf file in the specific temporary 
        directory containing the specific project of a source package.
 
     :param config Config: The global configuration.
     :param application_tmp_dir str: The path to the temporary application 
-                                       scripts directory of the project.
+                                    scripts directory of the project.
     '''
-    # read the pyconf of the application
     application_name = config.VARS.application
-    application_pyconf_path = src.find_file_in_lpath(
-                                            application_name + ".pyconf",
-                                            config.PATHS.APPLICATIONPATH)
-    application_pyconf_cfg = src.pyconf.Config(application_pyconf_path)
-    
-    # Change the workdir
-    application_pyconf_cfg.APPLICATION.workdir = src.pyconf.Reference(
-                                    application_pyconf_cfg,
-                                    src.pyconf.DOLLAR,
-                                    'VARS.salometoolsway + $VARS.sep + ".."')
-
-    # Prevent from compilation in base
-    application_pyconf_cfg.APPLICATION.base = "no"
-    
-    #remove products that are not in config (which were filtered by --without_properties)
-    for product_name in application_pyconf_cfg.APPLICATION.products.keys():
-        if product_name not in config.APPLICATION.products.keys():
-            application_pyconf_cfg.APPLICATION.products.__delitem__(product_name)
-
     # write the pyconf file to the temporary application location
     application_tmp_pyconf_path = os.path.join(application_tmp_dir,
                                                application_name + ".pyconf")
-
-    ff = open(application_tmp_pyconf_path, 'w')
-    ff.write("#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\n")
-    application_pyconf_cfg.__save__(ff, 1)
-    ff.close()
+    with open(application_tmp_pyconf_path, 'w') as f:
+        f.write("#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\n")
+        res = src.pyconf.Config()
+        app = src.pyconf.deepCopyMapping(config.APPLICATION)
+        # no base in packages
+        if "base" in app:
+            app.base = "no" 
+        # Change the workdir
+        app.workdir = src.pyconf.Reference(
+                                 app,
+                                 src.pyconf.DOLLAR,
+                                 'VARS.salometoolsway + $VARS.sep + ".."')
+        res.addMapping("APPLICATION", app, "")
+        res.__save__(f, evaluated=False)
+    
 
 def sat_package(config, tmp_working_dir, options, logger):
     '''Prepare a dictionary that stores all the needed directories and files to