From fbb950b13f7f33b2b38ba4c3c8b7b77bfacb6c1a Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Wed, 21 Mar 2018 09:50:05 +0100 Subject: [PATCH] fix #10458 --- commands/compile.py | 12 +++++++----- commands/generate.py | 1 + src/environment.py | 28 ++++++++++++++++++++-------- src/fileEnviron.py | 19 +++++++++++++++++-- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/commands/compile.py b/commands/compile.py index 2859abd..0f4d13f 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -299,8 +299,10 @@ def compile_all_products(sat, config, options, products_infos, logger): logger.flush() # Do nothing if the product is not compilable - if ("properties" in p_info and "compilation" in p_info.properties and - p_info.properties.compilation == "no"): + if ("properties" in p_info and + "compilation" in p_info.properties and + p_info.properties.compilation == "no"): + log_step(logger, header, "ignored") logger.write("\n", 3, False) continue @@ -340,18 +342,18 @@ def compile_all_products(sat, config, options, products_infos, logger): # Check if sources was already successfully installed check_source = src.product.check_source(p_info) if not check_source: - logger.write(_("Sources of product not found (try 'sat -h prepare')\n")) + logger.write(_("Sources of product not found (try 'sat -h prepare') ")) res += 1 #BUG continue # Check if it was already successfully installed if src.product.check_installation(p_info): - logger.write(_("Already installed\n")) + logger.write(_("Already installed ")) continue # If the show option was called, do not launch the compilation if options.no_compile: - logger.write(_("Not installed\n")) + logger.write(_("Not installed ")) continue # Check if the dependencies are installed diff --git a/commands/generate.py b/commands/generate.py index c1c66c7..f0d1175 100644 --- a/commands/generate.py +++ b/commands/generate.py @@ -23,6 +23,7 @@ import imp import subprocess import src +import src.debug as DBG parser = src.options.Options() parser.add_option('p', 'products', 'list2', 'products', diff --git a/src/environment.py b/src/environment.py index c69f377..650efe5 100644 --- a/src/environment.py +++ b/src/environment.py @@ -22,6 +22,8 @@ import string import sys import src +import src.debug as DBG +import pprint as PP class Environ: '''Class to manage the environment context @@ -40,9 +42,7 @@ class Environ: def __repr__(self): """easy non exhaustive quick resume for debug print """ - res={} - res["environ"]=self.environ - return self.__class__.__name__ + str(res)[0:-1] + " ...etc...}" + return "%s(\n%s\n)" % (self.__class__.__name__, PP.pformat(self.environ)) def _expandvars(self, value): '''replace some $VARIABLE into its actual value in the environment @@ -191,11 +191,13 @@ class SalomeEnviron: self.silent = False def __repr__(self): - """easy non exhaustive quick resume for debug print""" - res={} - res["environ"]=str(self.environ) - res["forBuild"]=self.forBuild - return self.__class__.__name__ + str(res)[0:-1] + " ...etc...}" + """easy almost exhaustive quick resume for debug print""" + res = { + "environ" : self.environ, + "forBuild" : self.forBuild, + "for_package" : self.for_package, + } + return "%s(\n%s\n)" % (self.__class__.__name__, PP.pformat(res)) def append(self, key, value, sep=os.pathsep): '''append value to key using sep @@ -333,6 +335,13 @@ class SalomeEnviron: :param logger Logger: The logger instance to display messages """ + # add variable PRODUCT_ROOT_DIR as $workdir in APPLICATION.environ section if not present + try: + tmp = self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR + except: + self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR = src.pyconf.Reference(self.cfg, src.pyconf.DOLLAR, "workdir") + DBG.write("set_application_env add default Config.APPLICATION.environ.PRODUCT_ROOT_DIR", self.cfg.APPLICATION.environ) + # Set the variables defined in the "environ" section if 'environ' in self.cfg.APPLICATION: # we write PRODUCT environment it in order to conform to @@ -363,6 +372,7 @@ class SalomeEnviron: :param logger Logger: The logger instance to display messages """ # set root dir + DBG.write("set_salome_minimal_product_env", product_info) root_dir = product_info.name + "_ROOT_DIR" if not self.is_defined(root_dir): if 'install_dir' in product_info and product_info.install_dir: @@ -677,6 +687,8 @@ class SalomeEnviron: :param logger Logger: The logger instance to display messages :param env_info list: the list of products """ + DBG.write("set_full_environ for", env_info) + # DBG.write("set_full_environ config", self.cfg.APPLICATION.environ, True) # set product environ self.set_application_env(logger) diff --git a/src/fileEnviron.py b/src/fileEnviron.py index 10cefbc..8ff7a2f 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -17,6 +17,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os +import pprint as PP +import src.debug as DBG bat_header="""@echo off @@ -97,7 +99,7 @@ def get_file_environ(output, shell, environ=None): return ContextFileEnviron(output, environ) raise Exception("FileEnviron: Unknown shell = %s" % shell) -class FileEnviron: +class FileEnviron(object): """Base class for shell environment """ def __init__(self, output, environ=None): @@ -108,6 +110,15 @@ class FileEnviron: """ self._do_init(output, environ) + def __repr__(self): + """easy non exhaustive quick resume for debug print""" + res = { + "output" : self.output, + "environ" : self.environ, + } + return "%s(\n%s\n)" % (self.__class__.__name__, PP.pformat(res)) + + def _do_init(self, output, environ=None): """Initialization @@ -117,9 +128,13 @@ class FileEnviron: self.output = output self.toclean = [] if environ is not None: + #if str(type(environ)) == "": + if id(environ) == id(os.environ): + DBG.tofix("set %s environ as python os.environ, are you sure it is safe ?" % self.__class__.__name__, True) self.environ = environ else: - self.environ = os.environ + DBG.tofix("set %s environ as COPY of python os.environ, are you sure it is safe ?" % self.__class__.__name__, True) + self.environ = dict(os.environ) #make a copy cvw 180320 def add_line(self, number): """Add some empty lines in the shell file -- 2.39.2