From: Serge Rehbinder Date: Wed, 3 Aug 2016 07:16:09 +0000 (+0200) Subject: Be able to produce a relative environment for a package launcher X-Git-Tag: 5.0.0a0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba581fc52e94595b21b9360d78d991ad121588c2;p=tools%2Fsat.git Be able to produce a relative environment for a package launcher --- diff --git a/commands/launcher.py b/commands/launcher.py index c706a3a..537aecb 100644 --- a/commands/launcher.py +++ b/commands/launcher.py @@ -96,7 +96,7 @@ def generate_launch_file(config, # Write the launcher file logger.write(_("Generating launcher for %s :\n") % src.printcolors.printcLabel(config.VARS.application), 1) - logger.write(" %s\n" %src.printcolors.printcLabel(filepath), 1) + logger.write(" %s\n" % src.printcolors.printcLabel(filepath), 1) # open the file and write into it launch_file = open(filepath, "w") diff --git a/src/__init__.py b/src/__init__.py index f4c065d..d397783 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -330,3 +330,13 @@ def parse_date(date): date[11:13], date[13:]) return res + +def merge_dicts(*dict_args): + ''' + Given any number of dicts, shallow copy and merge into a new dict, + precedence goes to key value pairs in latter dicts. + ''' + result = {} + for dictionary in dict_args: + result.update(dictionary) + return result diff --git a/src/environment.py b/src/environment.py index 721fbee..668191a 100644 --- a/src/environment.py +++ b/src/environment.py @@ -167,7 +167,7 @@ class SalomeEnviron: """Class to manage the environment of SALOME. """ - def __init__(self, cfg, environ, forBuild=False): + def __init__(self, cfg, environ, forBuild=False, for_package=None): '''Initialization. :param cfg Config: the global config @@ -175,10 +175,13 @@ class SalomeEnviron: to store the environment variables :param forBuild bool: If true, it is a launch environment, else a build one + :param for_package str: If not None, produce a relative environment + designed for a package. ''' self.environ = environ self.cfg = cfg self.forBuild = forBuild + self.for_package = for_package self.silent = False def __repr__(self): @@ -372,12 +375,13 @@ class SalomeEnviron: elif not self.silent: logger.write(" " + _("No install_dir for product %s\n") % product_info.name, 5) - - # set source dir, unless no source dir - if not src.product.product_is_fixed(product_info): - src_dir = product_info.name + "_SRC_DIR" - if not self.is_defined(src_dir): - self.set(src_dir, product_info.source_dir) + + if not self.for_package: + # set source dir, unless no source dir + if not src.product.product_is_fixed(product_info): + src_dir = product_info.name + "_SRC_DIR" + if not self.is_defined(src_dir): + self.set(src_dir, product_info.source_dir) def set_salome_generic_product_env(self, product): """Sets the generic environment for a SALOME product. @@ -478,6 +482,9 @@ class SalomeEnviron: # Get the informations corresponding to the product pi = src.product.get_product_config(self.cfg, product) + if self.for_package: + pi.install_dir = os.path.join(self.for_package, pi.name) + # Do not define environment if the product is native if src.product.product_is_native(pi): return @@ -669,24 +676,32 @@ class FileEnvWriter: return env_file.name - def write_cfgForPy_file(self, filename, additional_env = {}): + def write_cfgForPy_file(self, + filename, + additional_env = {}, + for_package = None): """Append to current opened aFile a cfgForPy environment (SALOME python launcher). :param filename str: the file path :param additional_env dict: a dictionary of additional variables to add to the environment + :param for_package str: If not None, produce a relative environment + designed for a package. """ if not self.silent: self.logger.write(_("Create configuration file %s\n") % - src.printcolors.printcLabel(aFile.name), 3) + src.printcolors.printcLabel(filename.name), 3) # create then env object tmp = src.fileEnviron.get_file_environ(filename, "cfgForPy", {}) # environment for launch - env = SalomeEnviron(self.config, tmp, forBuild=False) + env = SalomeEnviron(self.config, + tmp, + forBuild=False, + for_package=for_package) env.silent = self.silent if self.env_info is not None: diff --git a/src/logger.py b/src/logger.py index 0b31fba..6aeb94b 100644 --- a/src/logger.py +++ b/src/logger.py @@ -164,6 +164,7 @@ class Logger(object): else: if self.default_level <= current_output_verbose_level and not self.silentSysStd: sys.stdout.write(message) + self.flush() def error(self, message): '''Print an error. diff --git a/src/product.py b/src/product.py index 211c0b6..0f68482 100644 --- a/src/product.py +++ b/src/product.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -'''In this file are implemented the classes and methods +'''In this file are implemented the methods relative to the product notion of salomeTools ''' @@ -77,11 +77,13 @@ def get_product_config(config, product_name): # If it exists, get the information of the product_version if "version_" + vv in config.PRODUCTS[product_name]: # returns specific information for the given version - prod_info = config.PRODUCTS[product_name]["version_" + vv] + prod_info = config.PRODUCTS[product_name]["version_" + vv] + prod_info.section = "version_" + vv # Get the standard informations elif "default" in config.PRODUCTS[product_name]: # returns the generic information (given version not found) prod_info = config.PRODUCTS[product_name].default + prod_info.section = "default" # merge opt_depend in depend if prod_info is not None and 'opt_depend' in prod_info: @@ -155,9 +157,9 @@ def get_product_config(config, product_name): else: if (os.path.basename(prod_info.archive_info.archive_name) == prod_info.archive_info.archive_name): - + arch_name = prod_info.archive_info.archive_name arch_path = src.find_file_in_lpath( - prod_info.archive_info.archive_name, + arch_name, config.PATHS.ARCHIVEPATH) if not arch_path: msg = _("Archive %(arch_name)s for %(prod_name)s not found:" @@ -217,7 +219,7 @@ def get_product_config(config, product_name): prod_info.compil_script) # Get the full paths of all the patches - if "patches" in prod_info: + if product_has_patches(prod_info): patches = [] for patch in prod_info.patches: patch_path = patch @@ -236,7 +238,7 @@ def get_product_config(config, product_name): prod_info.patches = patches # Get the full paths of the environment scripts - if "environ" in prod_info and "env_script" in prod_info.environ: + if product_has_env_script(prod_info): env_script_path = prod_info.environ.env_script # If only a filename, then search for the environment script # in the PRODUCTPATH/env_scripts @@ -427,4 +429,24 @@ def product_has_script(product_info): # Native case return False build_src = product_info.build_source - return build_src.lower() == 'script' \ No newline at end of file + return build_src.lower() == 'script' + +def product_has_env_script(product_info): + '''Know if a product has an environment script + + :param product_info Config: The configuration specific to + the product + :return: True if the product it has an environment script, else False + :rtype: boolean + ''' + return "environ" in product_info and "env_script" in product_info.environ + +def product_has_patches(product_info): + '''Know if a product has one or more patches + + :param product_info Config: The configuration specific to + the product + :return: True if the product has one or more patches + :rtype: boolean + ''' + return "patches" in product_info and len(product_info.patches) > 0 \ No newline at end of file diff --git a/src/xsl/jobs_board_report.xsl b/src/xsl/jobs_board_report.xsl index 837c1fd..0f8bef9 100644 --- a/src/xsl/jobs_board_report.xsl +++ b/src/xsl/jobs_board_report.xsl @@ -189,7 +189,7 @@ javascript:Toggle('') OK2day - j + job