From: Serge Rehbinder Date: Wed, 21 Sep 2016 07:56:48 +0000 (+0200) Subject: sat source: Adding the application environment when getting sources of a product X-Git-Tag: 5.0.0a1~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=37d0c6c103a63283b6771c187e8109dd31c22891;p=tools%2Fsat.git sat source: Adding the application environment when getting sources of a product --- diff --git a/commands/source.py b/commands/source.py index 79068ce..8ca970d 100644 --- a/commands/source.py +++ b/commands/source.py @@ -60,7 +60,12 @@ def get_source_for_dev(config, product_info, source_dir, logger, pad): return retcode -def get_source_from_git(product_info, source_dir, logger, pad, is_dev=False): +def get_source_from_git(product_info, + source_dir, + logger, + pad, + is_dev=False, + environ = None): '''The method called if the product is to be get in git mode :param product_info Config: The configuration specific to @@ -70,6 +75,8 @@ def get_source_from_git(product_info, source_dir, logger, pad, is_dev=False): :param logger Logger: The logger instance to use for the display and logging :param pad int: The gap to apply for the terminal display :param is_dev boolean: True if the product is in development mode + :param environ src.environment.Environ: The environment to source when + extracting. :return: True if it succeed, else False :rtype: boolean ''' @@ -99,7 +106,7 @@ def get_source_from_git(product_info, source_dir, logger, pad, is_dev=False): # Call the system function that do the extraction in git mode retcode = src.system.git_extract(repo_git, product_info.git_info.tag, - source_dir, logger) + source_dir, logger, environ) return retcode def get_source_from_archive(product_info, source_dir, logger): @@ -138,7 +145,13 @@ def get_source_from_archive(product_info, source_dir, logger): return retcode -def get_source_from_cvs(user, product_info, source_dir, checkout, logger, pad): +def get_source_from_cvs(user, + product_info, + source_dir, + checkout, + logger, + pad, + environ = None): '''The method called if the product is to be get in cvs mode :param user str: The user to use in for the cvs command @@ -149,6 +162,8 @@ def get_source_from_cvs(user, product_info, source_dir, checkout, logger, pad): :param checkout boolean: If True, get the source in checkout mode :param logger Logger: The logger instance to use for the display and logging :param pad int: The gap to apply for the terminal display + :param environ src.environment.Environ: The environment to source when + extracting. :return: True if it succeed, else False :rtype: boolean ''' @@ -196,10 +211,15 @@ def get_source_from_cvs(user, product_info, source_dir, checkout, logger, pad): product_info.cvs_info.product_base, product_info.cvs_info.tag, product_info.cvs_info.source, - source_dir, logger, checkout) + source_dir, logger, checkout, environ) return retcode -def get_source_from_svn(user, product_info, source_dir, checkout, logger): +def get_source_from_svn(user, + product_info, + source_dir, + checkout, + logger, + environ = None): '''The method called if the product is to be get in svn mode :param user str: The user to use in for the svn command @@ -209,6 +229,8 @@ def get_source_from_svn(user, product_info, source_dir, checkout, logger): directory where to put the sources :param checkout boolean: If True, get the source in checkout mode :param logger Logger: The logger instance to use for the display and logging + :param environ src.environment.Environ: The environment to source when + extracting. :return: True if it succeed, else False :rtype: boolean ''' @@ -228,7 +250,8 @@ def get_source_from_svn(user, product_info, source_dir, checkout, logger): product_info.svn_info.tag, source_dir, logger, - checkout) + checkout, + environ) return retcode def get_product_sources(config, @@ -252,6 +275,14 @@ def get_product_sources(config, :return: True if it succeed, else False :rtype: boolean ''' + + # Get the application environment + logger.write(_("Set the application environment\n"), 5) + env_appli = src.environment.SalomeEnviron(config, + src.environment.Environ(dict(os.environ))) + env_appli.set_application_env(logger) + + # Call the right function to get sources regarding the product settings if not checkout and is_dev: return get_source_for_dev(config, product_info, @@ -261,7 +292,7 @@ def get_product_sources(config, if product_info.get_source == "git": return get_source_from_git(product_info, source_dir, logger, pad, - is_dev) + is_dev,env_appli) if product_info.get_source == "archive": return get_source_from_archive(product_info, source_dir, logger) @@ -273,13 +304,15 @@ def get_product_sources(config, source_dir, checkout, logger, - pad) + pad, + env_appli) if product_info.get_source == "svn": svn_user = config.USER.svn_user return get_source_from_svn(svn_user, product_info, source_dir, checkout, - logger) + logger, + env_appli) if product_info.get_source == "native": # skip diff --git a/src/system.py b/src/system.py index 1969bac..78e9946 100644 --- a/src/system.py +++ b/src/system.py @@ -51,13 +51,15 @@ def show_in_editor(editor, filePath, logger): % filePath), 1) -def git_extract(from_what, tag, where, logger): +def git_extract(from_what, tag, where, logger, environment=None): '''Extracts sources from a git repository. :param from_what str: The remote git repository. :param tag str: The tag. :param where str: The path where to extract. :param logger Logger: The logger instance to use. + :param environment src.environment.Environ: The environment to source when + extracting. :return: True if the extraction is successful :rtype: boolean ''' @@ -81,8 +83,12 @@ def git_extract(from_what, tag, where, logger): logger.logTxtFile.write("\n" + command + "\n") logger.logTxtFile.flush() - res = subprocess.call(command, cwd=str(where.dir()), shell=True, - stdout=logger.logTxtFile, stderr=subprocess.STDOUT) + res = subprocess.call(command, + cwd=str(where.dir()), + env=environment.environ.environ, + shell=True, + stdout=logger.logTxtFile, + stderr=subprocess.STDOUT) return (res == 0) def archive_extract(from_what, where, logger): @@ -104,7 +110,7 @@ def archive_extract(from_what, where, logger): return False, None def cvs_extract(protocol, user, server, base, tag, product, where, - logger, checkout=False): + logger, checkout=False, environment=None): '''Extracts sources from a cvs repository. :param protocol str: The cvs protocol. @@ -116,6 +122,8 @@ def cvs_extract(protocol, user, server, base, tag, product, where, :param where str: The path where to extract. :param logger Logger: The logger instance to use. :param checkout boolean: If true use checkout cvs. + :param environment src.environment.Environ: The environment to source when + extracting. :return: True if the extraction is successful :rtype: boolean ''' @@ -147,11 +155,21 @@ def cvs_extract(protocol, user, server, base, tag, product, where, logger.logTxtFile.write("\n" + command + "\n") logger.logTxtFile.flush() - res = subprocess.call(command, cwd=str(where.dir()), shell=True, - stdout=logger.logTxtFile, stderr=subprocess.STDOUT) + res = subprocess.call(command, + cwd=str(where.dir()), + env=environment.environ.environ, + shell=True, + stdout=logger.logTxtFile, + stderr=subprocess.STDOUT) return (res == 0) -def svn_extract(user, from_what, tag, where, logger, checkout=False): +def svn_extract(user, + from_what, + tag, + where, + logger, + checkout=False, + environment=None): '''Extracts sources from a svn repository. :param user str: The user to be used. @@ -160,6 +178,8 @@ def svn_extract(user, from_what, tag, where, logger, checkout=False): :param where str: The path where to extract. :param logger Logger: The logger instance to use. :param checkout boolean: If true use checkout svn. + :param environment src.environment.Environ: The environment to source when + extracting. :return: True if the extraction is successful :rtype: boolean ''' @@ -187,6 +207,10 @@ def svn_extract(user, from_what, tag, where, logger, checkout=False): logger.write(command + "\n", 5) logger.logTxtFile.write("\n" + command + "\n") logger.logTxtFile.flush() - res = subprocess.call(command, cwd=str(where.dir()), shell=True, - stdout=logger.logTxtFile, stderr=subprocess.STDOUT) + res = subprocess.call(command, + cwd=str(where.dir()), + env=environment.environ.environ, + shell=True, + stdout=logger.logTxtFile, + stderr=subprocess.STDOUT) return (res == 0) \ No newline at end of file