# Print some informations
msg = _('Executing the check command in the build directories of the application')
- logger.info("%s %s\n" % (msg, UTS.label(config.VARS.application)))
-
- info = [(_("BUILD directory"),
- os.path.join(config.APPLICATION.workdir, 'BUILD'))]
- UTS.logger_info_tuples(logger, info)
+ msg = "%s %s" % (msg, UTS.label(config.VARS.application))
+ info = [(_("BUILD directory"), os.path.join(config.APPLICATION.workdir, 'BUILD'))]
+ msg = "\n" + UTS.formatTuples(info)
+ logger.info(msg)
# Call the function that will loop over all the products and execute
# the right command(s)
- res = check_all_products(config, products_infos, logger)
+ res = self.check_all_products(products_infos)
# Print the final state
- nb_products = len(products_infos)
- if res == 0:
- final_status = "<OK>"
+ good_result = sum(1 for r in res if r.isOk())
+ nbExpected = len(products_infos)
+ msgCount = "(%d/%d)" % (good_result, nbExpected)
+ if good_result == nbExpected:
+ status = "OK"
+ msg = _("command check")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
else:
- final_status = "<KO>"
-
- logger.info(_("\nCheck: %(status)s (%(1)d/%(2)d)\n") % \
- { 'status': final_status,
- '1': nb_products - res,
- '2': nb_products })
-
- return res
+ status = "KO"
+ msg = _("command check, some products have failed")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+
+ return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
-def check_all_products(config, products_infos, logger):
+ def check_all_products(self, products_infos):
"""
Execute the proper configuration commands
in each product build directory.
- :param config: (Config) The global configuration
:param products_info: (list)
List of (str, Config) => (product_name, product_info)
- :param logger: (Logger)
- The logger instance to use for the display and logging
- :return: (int) the number of failing commands.
+ :return: (list of RCO.ReturnCode) list of OK if it succeed
"""
- res = 0
+ res = []
for p_name_info in products_infos:
- res_prod = check_product(p_name_info, config, logger)
- if res_prod != 0:
- res += 1
+ res.append(self.check_product(p_name_info)
return res
-def check_product(p_name_info, config, logger):
+ def check_product(self, p_name_info):
"""
Execute the proper configuration command(s)
in the product build directory.
:param p_name_info: (tuple)
(str, Config) => (product_name, product_info)
- :param config: (Config) The global configuration
- :param logger: (Logger)
- The logger instance to use for the display and logging
- :return: (int) 1 if it fails, else 0.
+ :return: (RCO.ReturnCode)
"""
+ # shortcuts
+ runner = self.getRunner()
+ config = self.getConfig()
+ logger = self.getLogger()
+ options = self.getOptions()
p_name, p_info = p_name_info
if ignored or not cmd_found:
UTS.log_step(logger, "ignored")
- logger.debug("==== %s %s\n" % (p_name, "IGNORED"))
if not cmd_found:
- return 1
- return 0
+ return RCO.ReturnCode("KO", "command not found product %s" % p_name)
+ return RCO.ReturnCode("OK", "ignored product %s" % p_name)
# Instantiate the class that manages all the construction commands
# like cmake, check, make install, make test, environment management, etc...
return RCO.ReturnCode("KO", "missing option (source/build/install/all) in clean command")
# Check with the user if he really wants to suppress the directories
- msg = _("Remove the following directories:\n")
- for directory in l_dir_to_suppress:
- msg += " %s\n" % UTS.info(str(directory))
- if runner.getAnswer(msg[:-1]) == "No":
- return RCO.ReturnCode("OK", "user do not want to continue")
-
- # Suppress the list of paths
- suppress_directories(l_dir_to_suppress, logger)
+ if len(l_dir_to_suppress) > 1: # need one or more
+ msg = _("Remove the following directories:")
+ for directory in l_dir_to_suppress:
+ msg += "\n %s" % UTS.info(str(directory))
+ if runner.getAnswer(msg) == "NO":
+ return RCO.ReturnCode("OK", "user do not want to clean")
+ # Suppress the list of paths
+ suppress_directories(l_dir_to_suppress, logger)
+
return RCO.ReturnCode("OK", "Command clean done")
error_step = "CONFIGURE"
msg = _("sat configure problem")
logger.error(msg)
- return RCO.ReturnCode("KO", "sat configure %s problem" % p_name, (error_step, p_name, p_info.install_dir))
+ return RCO.ReturnCode("KO", "sat configure product %s problem" % p_name, (error_step, p_name, p_info.install_dir))
res.append(rc)
logger.error(msg)
return RCO.ReturnCode("KO", "sat makeinstall %s problem" % p_name, (error_step, p_name, p_info.install_dir))
- return RCO.ReturnCode("OK", "compile cmake autotools %s done" % p_name)
+ return RCO.ReturnCode("OK", "compile cmake autotools product %s done" % p_name)
def compile_product_script(self, p_name_info):
"""Execute the script build procedure in the product build directory.
# Logging and sat command call for the script step
script_path_display = UTS.label(p_info.compil_script)
- UTS.log_step(logger, "SCRIPT %s ..." % script_path_display)
+ UTS.log_step(logger, "SCRIPT %s" % script_path_display)
# res = sat.script(config.VARS.application + " --products " + p_name, verbose = 0, logger_add_link = logger)
cmd_args = "--products %s" % p_name
# the right command(s)
if options.option is None:
options.option = ""
- res = configure_all_products(config, products_infos, options.option, logger)
+
+ res = self.configure_all_products(products_infos)
- # Print the final state
- nb_products = len(products_infos)
- if res == 0:
- final_status = "<OK>"
+ good_result = sum(1 for r in res if r.isOk())
+ nbExpected = len(products_infos)
+ msgCount = "(%d/%d)" % (good_result, nbExpected)
+ if good_result == nbExpected:
+ status = "OK"
+ msg = _("command configure")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
else:
- final_status = "<KO>"
-
- logger.info(_("\nConfiguration: %(status)s (%(1)d/%(2)d)\n") % \
- { 'status': final_status,
- '1': nb_products - res,
- '2': nb_products }, 1)
-
- return res
+ status = "KO"
+ msg = _("command configure, some products have failed")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+
+ return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
-def configure_all_products(config, products_infos, conf_option, logger):
+
+
+ def configure_all_products(self, products_infos):
"""
Execute the proper configuration commands
in each product build directory.
- :param config: (Config) The global configuration
:param products_info: (list)
List of (str, Config) => (product_name, product_info)
- :param conf_option: (str) The options to add to the command
- :param logger: (Logger) The logger instance to use for the display and logging
- :return: (int) the number of failing commands.
- """
- res = 0
+ :return: (list of RCO.ReturnCode) list of OK if it succeed
+ """
+ res = []
for p_name_info in products_infos:
- res_prod = configure_product(p_name_info, conf_option, config, logger)
- if res_prod != 0:
- res += 1
+ res.append(self.configure_product(p_name_info))
return res
-def configure_product(p_name_info, conf_option, config, logger):
+ def configure_product(self, p_name_info):
"""
Execute the proper configuration command(s)
in the product build directory.
The logger instance to use for the display and logging
:return: (RCO.ReturnCode)
"""
+ # shortcuts
+ runner = self.getRunner()
+ config = self.getConfig()
+ logger = self.getLogger()
+ options = self.getOptions()
+
+ conf_option = options.option
p_name, p_info = p_name_info
# Logging
# Check that the command has been called with an application
UTS.check_config_has_application(config).raiseIfKo()
- logger.info( _('Generation of SALOME modules for application %s\n') % \
- UTS.label(config.VARS.application) )
+ msg = _('Generation of SALOME modules for application %s') % \
+ UTS.label(config.VARS.application)
+ logger.info(msg)
status = RCO._KO_STATUS
# verify that YACSGEN is available
- returnCode = check_yacsgen(config, options.yacsgen, logger)
-
- if not returnCode.isOk():
- logger.error(returnCode.getWhy())
- return returnCode
- else:
- yacsgen_dir = returnCode.getValue()
+ rc = check_yacsgen(config, options.yacsgen, logger)
+ if not rc.isOk():
+ logger.error(rc.getWhy())
+ return rc
+ # ok
+ yacsgen_dir = rc.getValue()
# Make the generator module visible by python
sys.path.insert(0, yacsgen_dir)
- logger.info(" insert directory PATH %s = %s\n" % \
+ logger.info(" insert directory PATH %s = %s" % \
("YACSGEN", UTS.blue(yacsgen_dir)) )
products = config.APPLICATION.products
logger.error(msg)
return RCO.ReturnCode("KO", msg)
else:
- return RCO.ReturnCode("OK", "generate command done")
+ return RCO.ReturnCode("OK", "command generate done")
def generate_component_list(config, product_info, context, logger):
products_infos = self.get_products_list(options, config)
# Print some informations
- logger.info(
- _('Executing the make command in the build directories of the application %s\n') % \
- UTS.label(config.VARS.application))
-
+ msg = _('Executing the make command in the build directories of the application %s') % \
+ UTS.label(config.VARS.application)
info = [(_("BUILD directory"), os.path.join(config.APPLICATION.workdir, 'BUILD'))]
- UTS.logger_info_tuples(logger, info)
+ msg += "\n" + UTS.formatTuples(info)
+ logger.info(msg)
# Call the function that will loop over all the products and execute
# the right command(s)
options.option = ""
res = make_all_products(config, products_infos, options.option, logger)
- # Print the final state
- nb_products = len(products_infos)
- if res == 0:
- final_status = "OK"
+ good_result = sum(1 for r in res if r.isOk())
+ nbExpected = len(products_infos)
+ msgCount = "(%d/%d)" % (good_result, nbExpected)
+ if good_result == nbExpected:
+ status = "OK"
+ msg = _("command make")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
else:
- final_status = "KO"
-
- msg = _("\nMake: <%s> (%d/%d)\n") % (final_status, nb_products - res, nb_products)
- logger.info(msg)
-
- return RCO.ReturnCode(final_status, msg)
+ status = "KO"
+ msg = _("command make, some products have failed")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+
+ return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
def make_all_products(config, products_infos, make_option, logger):
"""
:param make_option: (str) The options to add to the command
:param logger: (Logger)
The logger instance to use for the display and logging
- :return: (int) the number of failing commands.
+ :return: (list of RCO.ReturnCode)
"""
- res = 0
+ res = []
for p_name_info in products_infos:
- res_prod = make_product(p_name_info, make_option, config, logger)
- if res_prod != 0:
- res += 1
+ res.append(make_product(p_name_info, make_option, config, logger))
return res
def make_product(p_name_info, make_option, config, logger):
nb_proc, make_opt_without_j = get_nb_proc(p_info, config, make_option)
UTS.log_step(logger, "MAKE -j" + str(nb_proc))
+
if ARCH.is_windows():
res = builder.wmake(nb_proc, make_opt_without_j)
else:
res = builder.make(nb_proc, make_opt_without_j)
+
UTS.log_step(logger, res)
-
return res
def get_nb_proc(product_info, config, make_option):
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import os
import src.debug as DBG
import src.returnCode as RCO
# Call the function that will loop over all the products and execute
# the right command(s)
- res = makeinstall_all_products(config, products_infos, logger)
+ res = self.makeinstall_all_products(products_infos)
- # Print the final state
- nb_products = len(products_infos)
- if res == 0:
- final_status = "OK"
+ good_result = sum(1 for r in res if r.isOk())
+ nbExpected = len(products_infos)
+ msgCount = "(%d/%d)" % (good_result, nbExpected)
+ if good_result == nbExpected:
+ status = "OK"
+ msg = _("command makeinstall")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
else:
- final_status = "KO"
-
- msg = _("\nMake install: <%s> (%d/%d)\n") % (final_status, nb_products - res, nb_products)
- logger.info(msg)
-
- return RCO.ReturnCode(final_status, msg)
+ status = "KO"
+ msg = _("command makeinstall, some products have failed")
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+
+ return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
-def makeinstall_all_products(config, products_infos, logger):
+ def makeinstall_all_products(self, products_infos):
"""
Execute the proper configuration commands
in each product build directory.
- :param config: (Config) The global configuration
:param products_info: (list)
List of (str, Config) => (product_name, product_info)
- :param logger: (Logger)
- The logger instance to use for the display and logging
- :return: (int) the number of failing commands.
+ :return: (list of RCO.ReturnCode) list of OK if it succeed
"""
- res = 0
+ res = []
for p_name_info in products_infos:
- res_prod = makeinstall_product(p_name_info, config, logger)
- if res_prod != 0:
- res += 1
+ res.append(self.makeinstall_product(p_name_info))
return res
-def makeinstall_product(p_name_info, config, logger):
+ def makeinstall_product(self, p_name_info):
"""
Execute the proper configuration command(s)
in the product build directory.
:param config: (Config) The global configuration
:param logger: (Logger)
The logger instance to use for the display and logging
- :return: (int) 1 if it fails, else 0.
+ :return: (RCO.ReturnCode)
"""
+ # shortcuts
+ runner = self.getRunner()
+ config = self.getConfig()
+ logger = self.getLogger()
+ options = self.getOptions()
p_name, p_info = p_name_info
if ("properties" in p_info and \
"compilation" in p_info.properties and \
p_info.properties.compilation == "no"):
- UTS.log_step(logger, "ignored")
- return RCO.ReturnCode("OK", "product %s is not compilable" % p_name)
+ UTS.log_step(logger, "ignored")
+ return RCO.ReturnCode("OK", "product %s is not compilable" % p_name)
# Instantiate the class that manages all the construction commands
# like cmake, make, make install, make test, environment management, etc...
# Prepare the environment
UTS.log_step(logger, "PREPARE ENV")
- res_prepare = builder.prepare()
- UTS.log_step(logger, res_prepare)
+ res = builder.prepare()
+ UTS.log_step(logger, res)
# Execute buildconfigure, configure if the product is autotools
# Execute cmake if the product is cmake
- res = TODO
if not PROD.product_has_script(p_info):
- UTS.log_step(logger, "MAKE INSTALL")
- res_m = builder.install()
- UTS.log_step(logger, res_m)
- res += res_m
+ UTS.log_step(logger, "MAKE INSTALL")
+ res_m = builder.install()
+ UTS.log_step(logger, res_m)
+ res += res_m
return res
self.launch_environ.silent = True # no need to show here
self.launch_environ.set_full_environ(logger, environ_info)
- msg = "build environment:\n"
+ msg = "build environment"
for ee in C_COMPILE_ENV_LIST:
vv = self.build_environ.get(ee)
if len(vv) > 0:
- msg += " %s = %s\n" % (ee, vv)
+ msg += "\n %s = %s" % (ee, vv)
logger.trace(msg)
return RCO.ReturnCode("OK", "prepare done")
}\\n\\
CC=\\"hack_libtool\\"%g" libtool'''
+ # just better but horreur yet
hack_cmd=r'''
set -x
sed -i "s%^CC=\"\(.*\)\"%hack_libtool() { \n\
cmd += cmd + " ALL_BUILD.vcxproj"
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=logger)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
cmd = 'make install'
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=logger)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
- def check(self, command=""):
+ def check(self, command=None):
"""Runs 'make_check'."""
logger = self.logger
if ARCH.is_windows():
else:
cmd = 'make test'
- if command:
+ if command is not None:
cmd = command
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env , logger=logger)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def do_python_script_build(self, script, nb_proc):
"""Performs a build with a script."""
+ import src.debug as DBG # Easy print stderr (for DEBUG only)
logger = self.logger
# script found
- logger.info(_("Compile %s using script %s\n") % \
- (self.product_info.name, UTS.label(script)) )
+ logger.trace(_("Compile %s using script %s\n") % \
+ (self.product_info.name, UTS.label(script)) )
+ self.nb_proc = nb_proc
+ # load
try:
import imp
product = self.product_info.name
pymodule = imp.load_source(product + "_compile_script", script)
+ except Exception as e:
+ msg = "Problem loading compile script\n%s" % script
+ logger.error(DBG.format_color_exception(msg))
+ return RCO.ReturnCode("KO", msg)
+ # execution
+ try:
self.nb_proc = nb_proc
- retcode = pymodule.compil(self.config, self, logger)
- except:
- __, exceptionValue, exceptionTraceback = sys.exc_info()
- logger.error(str(exceptionValue))
- import traceback
- traceback.print_tb(exceptionTraceback)
- traceback.print_exc()
- retcode = 1
- finally:
- self.put_txt_log_in_appli_log_dir("script")
- return retcode
+ retcode = pymodule.compil_SAT_51(self.config, self, logger)
+ return retcode
+ except Exception as e:
+ msg = "Problem execution method compil_SAT_51 compile script\n%s" % script
+ logger.error(DBG.format_color_exception(msg))
+ return RCO.ReturnCode("KO", msg)
def complete_environment(self, make_options):
assert self.build_environ is not None
self.STEP = _STEP
self.TRACE = _TRACE
+ def getMainCommandHandler(self):
+ """
+ returns handler for colored stdout console/terminal
+ for human user eye sat outputs
+ """
+ for h in self.handlers:
+ if h.idCommandHandlers == 0:
+ return h
+ return None
+
def close(self):
"""
final stuff for logger, done at end salomeTools
cmd = config.VARS.command
fullNameCmd = cmdInstance.getFullNameStr()
hostname = config.VARS.hostname
- nameFileXml = "%s_%02i_%s_%s.xml" % (datehour, self.idCommandHandlers, cmd, hostname)
- nameFileTxt = "%s_%02i_%s_%s.txt" % (datehour, self.idCommandHandlers, cmd, hostname)
+ nameFileXml = "%s_%03i_%s_%s.xml" % (datehour, self.idCommandHandlers, cmd, hostname)
+ nameFileTxt = "%s_%03i_%s_%s.txt" % (datehour, self.idCommandHandlers, cmd, hostname)
fileXml = os.path.join(log_dir, nameFileXml)
fileTxt = os.path.join(log_dir_out, nameFileTxt)
return cmdInstance
def runMicroCommand(self, cmdInstance, cmd_arguments):
- """launch a micro command on arguments"""
+ """
+ launch a micro command on arguments, from another command
+ set this micro command less verbose level as WARNING
+ to not pollute user main log
+ """
logger = self.getLogger()
commandArguments = self.assumeAsList(cmd_arguments)
# Run the micro command using the remainders command arguments
strArgs = " ".join(commandArguments)
msg = "BEGIN launch micro command %s on (%s)" % (cmdInstance.name, strArgs)
logger.step(msg)
+
+ # make micro command less verbose
+ mainHandler = logger.getMainCommandHandler()
+ oldLevel = mainHandler.level
+ mainHandler.setLevel("WARNING")
+
returnCode = cmdInstance.run(commandArguments)
+
+ # restore verbosity
+ mainHandler.setLevel(oldLevel)
+
msg = "END launch micro command %s on (%s)\n%s" % (cmdInstance.name, strArgs, str(returnCode))
- logger.step(msg)
+ if type(returnCode) != RCO.ReturnCode:
+ logger.critical(msg)
+ raise Exception("command %s: ReturnCode type unexpected %s" % (cmdInstance.name, type(returnCode)))
+
+ logger.step(msg)
import src.linksXml as LKXML
LKXML.setAttribLinkForCommand(cmdInstance, "full_launched_cmd", strArgs)
LKXML.setAttribLinkForCommand(cmdInstance, "cmd_res", returnCode.toXmlPassed())
-
logger.closeFileHandlerForCommand(cmdInstance)
return returnCode
logger.step(msg)
returnCode = cmdInstance.run(commandArguments)
msg = "END main launch command %s on (%s)\n%s" % (self.nameCommandToLoad, strArgs, str(returnCode))
+
+ if type(returnCode) != RCO.ReturnCode:
+ logger.critical(msg)
+ raise Exception("command %s: ReturnCode type unexpected %s" % (cmdInstance.name, type(returnCode)))
+
logger.step(msg)
import src.linksXml as LKXML
def log_step(logger, step):
header = _log_step_header[-1]
if type(step) == str:
- logger.info("<RC>%s%s ..." % (header, step))
+ logger.info("<RC>%s %s ..." % (header, step))
return
#as ReturnCode type step
if step.isOk():
logger.info("<RC>%s <OK>..." % header)
else:
- logger.info("<RC>%s%s <KO>..." % (header, step.getwhy()))
+ logger.info("<RC>%s%s <KO>..." % (header, step.getWhy()))
def end_log_step(logger, step):
header = _log_step_header[-1]
if type(step) == str:
- logger.info("<RC>%s%s" % (header, step))
+ logger.info("<RC>%s %s" % (header, step))
if len(_log_step_header) > 1: _log_step_header.pop()
return
#as ReturnCode type