]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Fix bug for package command
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 6 Sep 2016 08:30:45 +0000 (10:30 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 6 Sep 2016 08:30:45 +0000 (10:30 +0200)
commands/config.py
commands/package.py
src/__init__.py
src/environment.py
src/fileEnviron.py
src/pyconf.py

index 02d0cc51ee82d37815ea3f03c42a36480e696326..115984ae68455d03ab05a27d0e64a85c5dac04c5 100644 (file)
@@ -247,7 +247,8 @@ class ConfigManager:
         src.pyconf.streamOpener = ConfigOpener([cfg.VARS.datadir])
         try:
             site_cfg = src.pyconf.Config(open(os.path.join(cfg.VARS.datadir, 
-                                                           'site.pyconf')))
+                                                           'site.pyconf')),
+                                         PWD = ('SITE', cfg.VARS.datadir) )
         except src.pyconf.ConfigError as e:
             raise src.SatException(_("Error in configuration file: "
                                      "site.pyconf\n  %(error)s") % \
@@ -261,7 +262,6 @@ class ConfigManager:
                   + cfg.VARS.sep 
                   + "site.pyconf and edit the file")
             raise src.SatException( e );
-        
         merger.merge(cfg, site_cfg)
 
         # apply overwrite from command line if needed
@@ -287,7 +287,9 @@ class ConfigManager:
             project_name = os.path.basename(
                                     project_pyconf_path)[:-len(".pyconf")]
             try:
-                project_cfg = src.pyconf.Config(open(project_pyconf_path))
+                project_pyconf_dir = os.path.dirname(project_pyconf_path)
+                project_cfg = src.pyconf.Config(open(project_pyconf_path),
+                                                PWD=("", project_pyconf_dir))
             except Exception as e:
                 raise src.SatException(_("Error in configuration file: "
                                  "%(file_path)s\n  %(error)s") % \
@@ -354,7 +356,8 @@ class ConfigManager:
                     try:
                         prod_cfg = src.pyconf.Config(open(
                                                     os.path.join(products_dir,
-                                                                 fName)))
+                                                                 fName)),
+                                                     PWD=("", products_dir))
                     except src.pyconf.ConfigError as e:
                         raise src.SatException(_(
                             "Error in configuration file: %(prod)s\n  %(error)s") % \
index ad505353792d00e2d7b21775a2355b3ca11bf773..d5c8cf15b0097ca541d200888e09fa2e30429948 100644 (file)
@@ -35,9 +35,9 @@ PROJECT_TEMPLATE = """#!/usr/bin/env python
 #-*- coding:utf-8 -*-
 
 # The path to the archive root directory
-root_path : ""
+root_path : $PWD + "/../"
 # path to the PROJECT
-project_path : $root_path + "PROJECT/"
+project_path : $PWD + "/"
 
 # Where to search the archives of the products
 ARCHIVEPATH : $root_path + "ARCHIVES"
@@ -123,7 +123,7 @@ def add_files(tar, name_archive, d_content, logger):
             logger.write(src.printcolors.printcSuccess(_("OK")), 3)
         except Exception as e:
             logger.write(src.printcolors.printcError(_("KO ")), 3)
-            logger.write(e, 3)
+            logger.write(str(e), 3)
             success = 1
         logger.write("\n", 3)
     return success
@@ -149,8 +149,13 @@ def produce_relative_launcher(config,
     # Get the launcher template
     profile_install_dir = os.path.join(binaries_dir_name,
                                        config.APPLICATION.profile.product)
-    withProfile = src.fileEnviron.withProfile.replace( "PROFILE_INSTALL_DIR",
-                                                       profile_install_dir )
+    withProfile = src.fileEnviron.withProfile   
+    withProfile = withProfile.replace(
+        "ABSOLUTE_APPLI_PATH'] = 'PROFILE_INSTALL_DIR'",
+        "ABSOLUTE_APPLI_PATH'] = out_dir_Path + '/" + profile_install_dir + "'")
+    withProfile = withProfile.replace(
+        "os.path.join( 'PROFILE_INSTALL_DIR'",
+        "os.path.join( out_dir_Path, '" + profile_install_dir + "'")
 
     before, after = withProfile.split(
                                 "# here your local standalone environment\n")
@@ -170,6 +175,9 @@ def produce_relative_launcher(config,
     launch_file.write(after)
     launch_file.close()
     
+    # Little hack to put out_dir_Path outside the strings
+    src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' )
+    
     # change the rights in order to make the file executable for everybody
     os.chmod(filepath,
              stat.S_IRUSR |
@@ -648,7 +656,9 @@ def project_package(project_file_path, tmp_working_dir):
         project_pyconf_cfg.addMapping("project_path",
                                       src.pyconf.Mapping(project_pyconf_cfg),
                                       "")
-    project_pyconf_cfg.project_path = ""
+    project_pyconf_cfg.project_path = src.pyconf.Reference(project_pyconf_cfg,
+                                                           src.pyconf.DOLLAR,
+                                                           'PWD')
     
     # Write the project pyconf file
     project_file_name = os.path.basename(project_file_path)
@@ -844,4 +854,4 @@ def run(args, runner, logger):
     logger.write("\n", 2)
     src.printcolors.print_value(logger, "Package path", path_targz, 2)
     
-    return res
\ No newline at end of file
+    return res
index 7a4ac04af6224aa37a7cfb13a3d6c320e771ba2d..10783b7df58df4fccccd9fbc9f91b84d7cad4d17 100644 (file)
@@ -342,3 +342,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
index a0cb5bbce93372b63776b4ab126c916031e9f728..5ad12b0675ec764bd4ba2b622cabbec468e835df 100644 (file)
@@ -484,7 +484,9 @@ class SalomeEnviron:
         pi = src.product.get_product_config(self.cfg, product)
         
         if self.for_package:
-            pi.install_dir = os.path.join(self.for_package, pi.name)
+            pi.install_dir = os.path.join("out_dir_Path",
+                                          self.for_package,
+                                          pi.name)
                     
         # Do not define environment if the product is native
         if src.product.product_is_native(pi):
index 3ed76b39438713174bf99def000a90a9d18c5e6c..d88721cf3ea5b8e3b58f51560d56d76edb8a7b7a 100644 (file)
@@ -634,9 +634,7 @@ import sys
 
 # Add the pwdPath to able to run the launcher after unpacking a package
 # Used only in case of a salomeTools package
-out_dir_Path=os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname((os.path.abspath(os.path.dirname(__file__)))))))
-prereq_install_Path=os.path.join(out_dir_Path , 'PREREQUISITES', 'INSTALL')
-prereq_build_Path=os.path.join(out_dir_Path , 'PREREQUISITES', 'BUILD')
+out_dir_Path=os.path.abspath(os.path.dirname(__file__))
 
 # Preliminary work to initialize path to SALOME Python modules
 def __initialize():
index 944826cdb32b8875fd92374122cdad98998d5dd0..1eaea9f74458405834aa82026cf60853de2bb96d 100644 (file)
@@ -646,7 +646,7 @@ class Config(Mapping):
             self.sys = sys
             self.os = os
 
-    def __init__(self, streamOrFile=None, parent=None):
+    def __init__(self, streamOrFile=None, parent=None, PWD = None):
         """
         Initializes an instance.
 
@@ -675,6 +675,13 @@ class Config(Mapping):
                 streamOrFile = streamOpener(streamOrFile)
             load = object.__getattribute__(self, "load")
             load(streamOrFile)
+            # Specific add for salomeTools : PWD
+            if PWD:
+                key, pwd = PWD
+                if key == "":
+                    self.PWD = pwd
+                else:
+                    self[key].PWD = pwd
 
     def load(self, stream):
         """