p_name, p_info = p_name_info
header = _("Check of %s") % UTS.label(p_name)
- header += " %s " % ("." * (20 - len(p_name)))
- logger.info(header)
+ UTS.init_log_step(logger,header)
# Verify if the command has to be launched or not
ignored = False
logger.warning(msg)
if ignored or not cmd_found:
- UTS.log_step(logger, header, "ignored")
+ UTS.log_step(logger, "ignored")
logger.debug("==== %s %s\n" % (p_name, "IGNORED"))
if not cmd_found:
return 1
builder = COMP.Builder(config, logger, p_info)
# Prepare the environment
- UTS.log_step(logger, header, "PREPARE ENV")
+ UTS.log_step(logger, "PREPARE ENV")
res_prepare = builder.prepare()
- UTS.log_res_step(logger, res_prepare)
-
- len_end_line = 20
+ UTS.log_step(logger, res_prepare)
# Launch the check
- UTS.log_step(logger, header, "CHECK")
+ UTS.log_step(logger, "CHECK")
res = builder.check(command=command)
- UTS.log_res_step(logger, res)
-
- # Log the result
- if res > 0:
- logger.info("\r%s%s" % (header, " " * len_end_line))
- logger.info("\r" + header + "<KO>\n")
- logger.debug("==== <KO> in check of %s\n" % p_name)
- else:
- logger.info("\r%s%s" % (header, " " * len_end_line))
- logger.info("\r" + header + "<OK>\n")
- logger.debug("==== <OK> in check of %s\n" % p_name)
- logger.info("\n")
+ UTS.log_step(logger, res)
return res
The logger instance to use for the display and logging
"""
for path in l_paths:
- strpath = str(path)
- if not path.isdir():
- msg = _("The path %s does not exists (or is not a directory)") % UTS.info(strpath)
- logger.warning(msg)
- else:
- path.rm()
- logger.info(_("Remove %s ...<OK>") % UTS.info(strpath))
+ strpath = str(path)
+ if path.isfile():
+ msg = _("The path %s is file, expected directory)") % UTS.info(strpath)
+ logger.warning(msg)
+ if not path.isdir():
+ msg = _("The path %s does not exists (or is not a directory)") % UTS.info(strpath)
+ logger.trace(msg)
+ else:
+ path.rm()
+ logger.trace(_("Remove %s <OK>") % UTS.info(strpath))
import src.product as PROD
from src.salomeTools import _BaseCommand
-# Compatibility python 2/3 for input function
-# input stays input for python 3 and input = raw_input for python 2
-try:
- input = raw_input
-except NameError:
- pass
########################################################################
# Command class
# Warn the user if he invoked the clean_all option
# without --products option
- if (options.clean_all and
- options.products is None and
- not runner.options.batch):
- rep = input(_("You used --clean_all without specifying a product"
- " are you sure you want to continue? [Yes/No] "))
- if rep.upper() != _("YES").upper():
- return 0
-
+
+ if (options.clean_all and options.products is None):
+ msg = _("You used --clean_all without specifying a product, erasing all.")
+ if runner.getAnswer(msg) == "NO":
+ return RCO.ReturnCode("OK", "user do not want to continue")
+ runner.setConfirmMode(False) # user agree for all next
+
# check that the command has been called with an application
UTS.check_config_has_application(config).raiseIfKo()
srcDir = os.path.join(config.APPLICATION.workdir, 'SOURCES')
buildDir = os.path.join(config.APPLICATION.workdir, 'BUILD')
- msg = _("Application %s, executing compile commands in build directories of products.\n")
- logger.info(msg % UTS.label(nameApp))
-
+ msg = _("Application %s, executing compile commands in build directories of products.") % \
+ UTS.label(nameApp)
info = [ (_("SOURCE directory"), UTS.info(srcDir)),
- (_("BUILD directory"), UTS.info(buildDir)) ]
- UTS.logger_info_tuples(logger, info)
+ (_("BUILD directory"), UTS.info(buildDir)) ]
+ msg += "\n" + UTS.formatTuples(info)
+ logger.info(msg)
# Get the list of products to treat
products_infos = self.get_products_list(options, config)
res = [] # list of results for each products
DBG.write("compile", [p for p, tmp in products_infos])
+ header = None
for p_name_info in products_infos:
p_name, p_info = p_name_info
+ if header is not None: # close previous step in for loop
+ UTS.end_log_step(logger, res[-1])
+
# Logging
- len_end_line = 30
header = _("Compilation of %s ...") % UTS.label(p_name)
- logger.info(header)
+ UTS.init_log_step(logger, header)
# 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"):
- UTS.log_step(logger, header, "ignored")
+ UTS.log_step(logger, "ignored")
res.append(RCO.ReturnCode("OK", "compile %s ignored" % p_name))
continue
# Do nothing if the product is native
if PROD.product_is_native(p_info):
- UTS.log_step(logger, header, "native")
+ UTS.log_step(logger, "native")
res.append(RCO.ReturnCode("OK", "no compile %s as native" % p_name))
continue
# Clean the build and the install directories
# if the corresponding options was called
if options.clean_all:
- UTS.log_step(logger, header, "CLEAN BUILD AND INSTALL")
+ UTS.log_step(logger, "CLEAN BUILD AND INSTALL")
+ # import time
+ # time.sleep(5)
+ # UTS.log_step(logger, header, "IIYOO")
+ # raise Exception('YOO')
cmd_args = "--products %s --build --install" % p_name
rc = self.executeMicroCommand("clean", nameAppli, cmd_args)
if not rc.isOk():
# Clean the the install directory
# if the corresponding option was called
if options.clean_install and not options.clean_all:
- UTS.log_step(logger, header, "CLEAN INSTALL")
+ UTS.log_step(logger, "CLEAN INSTALL")
cmd_args = "--products %s --install" % p_name
rc = self.executeMicroCommand("clean", nameAppli, cmd_args)
if not rc.isOk():
# Check if it was already successfully installed
if PROD.check_installation(p_info):
- logger.info(_("Already installed"))
+ UTS.log_step(logger, _("already installed"))
res.append(RCO.ReturnCode("OK", "no compile %s as already installed" % p_name))
continue
# If the show option was called, do not launch the compilation
if options.no_compile:
- logger.info(_("No compile and install as show option"))
+ UTS.log_step(logger, _("No compile and install as show option"))
res.append(RCO.ReturnCode("OK", "no compile %s as show option" % p_name))
continue
# Check if the dependencies are installed
l_depends_not_installed = check_dependencies(config, p_name_info)
if len(l_depends_not_installed) > 0:
- UTS.log_step(logger, header, "<KO>")
+ UTS.log_step(logger, "<KO>")
msg = _("the following products are mandatory:\n")
for prod_name in sorted(l_depends_not_installed):
msg += "%s\n" % prod_name
continue
# Call the function to compile the product
- #res_prod, len_end_line, error_step = self.compile_product(p_name_info)
- #sat, p_name_info, config, options, logger, header, len_end_line)
rc = self.compile_product(p_name_info)
error_step, nameprod, install_dir = rc.getValue()
res.append(rc)
else:
# Ok Clean the build directory if the compilation and tests succeed
if options.clean_build_after:
- UTS.log_step(logger, header, "CLEAN BUILD")
+ UTS.log_step(logger, "CLEAN BUILD")
cmd_args = "--products %s --build" % p_name
rc0 = self.executeMicroCommand("clean", nameAppli, cmd_args)
- # Log the result
- if rc.isOk():
- logger.info("<KO> " + rc.getWhy())
- else:
- logger.info("<KO> " + rc.getWhy())
if not rc.isOk() and options.stop_first_fail:
- break # stop at first problem
+ logger.warning("Stop on first fail option activated")
+ break # stop at first problem
+
+
+ if header is not None: # close last step in for loop
+ UTS.end_log_step(logger, res[-1])
resAll = RCO.ReturnCodeFromList(res)
nbOk = len([r for r in res if r.isOk()])
else:
return RCO.ReturnCode("KO", "Existing %s failing compile product(s)" % nbKo, nbOk)
- def compile_product(self, p_name_info): #sat, p_name_info, config, options, logger, header, len_end):
+ def compile_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
- :param header: (str) the header to display when logging
- :param len_end: (int) the length of the the end of line (used in display)
:return: (RCO.ReturnCode) KO if it fails.
"""
config = self.getConfig()
options = self.getOptions()
logger = self.getLogger()
- header = "yyyy" # TODO
nameAppli = config.VARS.application
p_name, p_info = p_name_info
# build_sources : script -> script executions
if (PROD.product_is_autotools(p_info) or PROD.product_is_cmake(p_info)):
rc = self.compile_product_cmake_autotools(p_name_info)
- # sat, p_name_info, config, options, logger, header, len_end)
+
if PROD.product_has_script(p_info):
rc = self.compile_product_script(p_name_info)
- # sat, p_name_info, config, options, logger, header, len_end)
# Check that the install directory exists
if rc.isOk() and not(os.path.exists(p_info.install_dir)):
if options.check:
# Do the unit tests (call the check command)
- UTS.log_step(logger, header, "CHECK")
+ UTS.log_step(logger, "CHECK")
cmd_args = "--products %s" % p_name
rc0 = self.executeMicroCommand("check", nameAppli, cmd_args)
if not rc0.isOk():
rc.setValue( ("COMPILE", p_name, p_info.install_dir) )
return rc
- def compile_product_cmake_autotools(self, p_name_info): #sat, p_name_info, config, options, logger, header, len_end):
+ def compile_product_cmake_autotools(self, p_name_info):
"""
Execute the proper build procedure for autotools or cmake
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
- :param header: (str) the header to display when logging
- :param len_end: (int) the length of the the end of line (used in display)
- :return: (int) 1 if it fails, else 0.
+ :return: (RCO.ReturnCode) KO if it fails.
"""
config = self.getConfig()
options = self.getOptions()
logger = self.getLogger()
-
+
+ nameAppli = config.VARS.application
p_name, p_info = p_name_info
# Execute "sat configure", "sat make" and "sat install"
- res = 0
+ res = []
error_step = ""
# Logging and sat command call for configure step
- len_end_line = len_end
- UTS.log_step(logger, header, "CONFIGURE")
- res_c = sat.configure(config.VARS.application + " --products " + p_name,
- verbose = 0,
- logger_add_link = logger)
- UTS.log_res_step(logger, res_c)
- res += res_c
-
- if res_c > 0:
- error_step = "CONFIGURE"
+ UTS.log_step(logger, "CONFIGURE")
+ cmd_args = "--products %s" % p_name
+ rc = self.executeMicroCommand("configure", nameAppli, cmd_args)
+ if not rc.isOk():
+ 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))
+
+ res.append(rc)
+
+ # Logging and sat command call for make step
+ # Logging take account of the fact that the product has a compilation script or not
+ if PROD.product_has_script(p_info):
+ # if the product has a compilation script,
+ # it is executed during make step
+ script_path_display = UTS.label(p_info.compil_script)
+ UTS.log_step(logger, "SCRIPT " + script_path_display)
else:
- # Logging and sat command call for make step
- # Logging take account of the fact that the product has a compilation
- # script or not
- if PROD.product_has_script(p_info):
- # if the product has a compilation script,
- # it is executed during make step
- scrit_path_display = UTS.label(
- p_info.compil_script)
- UTS.log_step(logger, header, "SCRIPT " + scrit_path_display)
- len_end_line = len(scrit_path_display)
- else:
- UTS.log_step(logger, header, "MAKE")
- make_arguments = config.VARS.application + " --products " + p_name
- # Get the make_flags option if there is any
- if options.makeflags:
- make_arguments += " --option -j" + options.makeflags
- res_m = sat.make(make_arguments,
- verbose = 0,
- logger_add_link = logger)
- UTS.log_res_step(logger, res_m)
- res += res_m
-
- if res_m > 0:
- error_step = "MAKE"
- else:
- # Logging and sat command call for make install step
- UTS.log_step(logger, header, "MAKE INSTALL")
- res_mi = sat.makeinstall(config.VARS.application +
- " --products " +
- p_name,
- verbose = 0,
- logger_add_link = logger)
-
- UTS.log_res_step(logger, res_mi)
- res += res_mi
-
- if res_mi > 0:
- error_step = "MAKE INSTALL"
-
- return res, len_end_line, error_step
-
- def compile_product_script(self, p_name_info): # sat, p_name_info, config, options, logger, header, len_end):
+ UTS.log_step(logger, "MAKE")
+
+ cmd_args = "--products %s" % p_name
+ # Get the make_flags option if there is any
+ if options.makeflags:
+ cmd_args += " --option -j%s" % options.makeflags
+ rc = self.executeMicroCommand("make", nameAppli, cmd_args)
+ if not rc.isOk():
+ error_step = "MAKE"
+ msg = _("sat make problem")
+ logger.error(msg)
+ return RCO.ReturnCode("KO", "sat make %s problem" % p_name, (error_step, p_name, p_info.install_dir))
+
+ res.append(rc)
+
+ # Logging and sat command call for make install step
+ UTS.log_step(logger, "MAKE INSTALL")
+ cmd_args = "--products %s" % p_name
+ rc = self.executeMicroCommand("makeinstall", nameAppli, cmd_args)
+ if not rc.isOk():
+ error_step = "MAKEINSTALL"
+ msg = _("sat makeinstall problem")
+ 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)
+
+ def compile_product_script(self, p_name_info):
"""Execute the script build procedure 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
- :param header: (str) the header to display when logging
- :param len_end: (int) the length of the the end of line (used in display)
- :return: (int) 1 if it fails, else 0.
+ :return: (RCO.ReturnCode) KO if it fails.
"""
config = self.getConfig()
options = self.getOptions()
logger = self.getLogger()
nameAppli = config.VARS.application
- header = "xxxx" # TODO
-
p_name, p_info = p_name_info
# Execute "sat configure", "sat make" and "sat install"
# Logging and sat command call for the script step
script_path_display = UTS.label(p_info.compil_script)
- UTS.log_step(logger, header, "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
res = self.executeMicroCommand("script", nameAppli, cmd_args)
- UTS.log_res_step(logger, res)
+ UTS.log_step(logger, res)
return res
# 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
########################################################################
class Command(_BaseCommand):
"""
- The configure command executes in the build directory commands
- corresponding to the compilation mode of the application products.
+ The configure command executes in the build directory
+ some commands corresponding to the compilation mode of
+ the application products.
The possible compilation modes are 'cmake', 'autotools', or 'script'.
| Here are the commands to be run:
logger.info(_('Configuring the sources of the application %s\n') %
UTS.label(config.VARS.application))
- info = [(_("BUILD directory"),
- os.path.join(config.APPLICATION.workdir, 'BUILD'))]
+ info = [(_("BUILD directory"), os.path.join(config.APPLICATION.workdir, 'BUILD'))]
UTS.logger_info_tuples(logger, info)
# Call the function that will loop over all the products and execute
: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)
"""
p_name, p_info = p_name_info
# Logging
header = _("Configuration of %s") % UTS.label(p_name)
- header += " %s " % ("." * (20 - len(p_name)))
- logger.info(header)
+ UTS.init_log_step(logger, header)
# Do nothing if he product is not compilable
if ("properties" in p_info and \
"compilation" in p_info.properties and \
p_info.properties.compilation == "no"):
-
- UTS.log_step(logger, header, "ignored")
- logger.info("\n")
- return 0
+ UTS.end_log_step(logger, "ignored")
+ return RCO.ReturnCode("OK", "configure %s ignored" % p_name)
# Instantiate the class that manages all the construction commands
# like cmake, make, make install, make test, environment management, etc...
builder = COMP.Builder(config, logger, p_info)
# Prepare the environment
- UTS.log_step(logger, header, "PREPARE ENV")
+ UTS.log_step(logger, "PREPARE ENV")
res_prepare = builder.prepare()
- UTS.log_res_step(logger, res_prepare)
+ UTS.log_step(logger, res_prepare)
# Execute buildconfigure, configure if the product is autotools
# Execute cmake if the product is cmake
- res = 0
+ res = []
if PROD.product_is_autotools(p_info):
- UTS.log_step(logger, header, "BUILDCONFIGURE")
- res_bc = builder.build_configure()
- UTS.log_res_step(logger, res_bc)
- res += res_bc
- UTS.log_step(logger, header, "CONFIGURE")
- res_c = builder.configure(conf_option)
- UTS.log_res_step(logger, res_c)
- res += res_c
+ UTS.log_step(logger, "BUILDCONFIGURE")
+ rc = builder.build_configure()
+ UTS.log_step(logger, rc)
+ res.append(rc)
+ UTS.log_step(logger, "CONFIGURE")
+ rc = builder.configure(conf_option)
+ UTS.log_step(logger, rc)
+ res.append(rc)
if PROD.product_is_cmake(p_info):
- UTS.log_step(logger, header, "CMAKE")
- res_cm = builder.cmake(conf_option)
- UTS.log_res_step(logger, res_cm)
- res += res_cm
-
- # Log the result
- if res > 0:
- logger.info("\r%s%s" % (header, " " * 20))
- logger.info("\r" + header + "<KO>")
- logger.debug("==== <KO> in configuration of %s\n" % p_name)
- else:
- logger.info("\r%s%s" % (header, " " * 20))
- logger.info("\r" + header + "<OK>")
- logger.debug("==== <OK> in configuration of %s\n" % p_name)
- logger.info("\n")
-
- return res
+ UTS.log_step(logger, "CMAKE")
+ rc = builder.cmake(conf_option)
+ UTS.log_step(logger, rc)
+ res.append(rc)
+
+ UTS.end_log_step(logger, rc.getStatus())
+ return RCO.ReturnCode(rc.getStatus(), "in configure %s" % p_name)
# Logging
header = _("Make of %s") % UTS.label(p_name)
- header += " %s " % ("." * (20 - len(p_name)))
- logger.info(header)
+ UTS.init_log_step(logger, header)
# Do nothing if he product is not compilable
if ("properties" in p_info and \
"compilation" in p_info.properties and \
p_info.properties.compilation == "no"):
- UTS.log_step(logger, header, "ignored")
+ UTS.log_step(logger, "ignored")
return 0
# Instantiate the class that manages all the construction commands
builder = COMP.Builder(config, logger, p_info)
# Prepare the environment
- UTS.log_step(logger, header, "PREPARE ENV")
+ UTS.log_step(logger, "PREPARE ENV")
res_prepare = builder.prepare()
- UTS.log_res_step(logger, res_prepare)
+ UTS.log_step(logger, res_prepare)
# Execute buildconfigure, configure if the product is autotools
# Execute cmake if the product is cmake
- len_end_line = 20
nb_proc, make_opt_without_j = get_nb_proc(p_info, config, make_option)
- UTS.log_step(logger, header, "MAKE -j" + str(nb_proc))
+ 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_res_step(logger, res)
+ UTS.log_step(logger, res)
- # Log the result
- if res > 0:
- logger.info("\r%s%s" % (header, " " * len_end_line))
- logger.info("\r" + header + "<KO>")
- logger.debug("==== <KO> in make of %s\n" % p_name)
- else:
- logger.info("\r%s%s" % (header, " " * len_end_line))
- logger.info("\r" + header + "<OK>")
- logger.debug("==== <OK> in make of %s\n" % p_name)
- logger.info("\n")
return res
def get_nb_proc(product_info, config, make_option):
# Logging
header = _("Make install of %s") % UTS.label(p_name)
- header += " %s " % ("." * (20 - len(p_name)))
- logger.info(header)
+ UTS.init_log_step(logger, header)
# Do nothing if he product is not compilable
if ("properties" in p_info and \
"compilation" in p_info.properties and \
p_info.properties.compilation == "no"):
- UTS.log_step(logger, header, "ignored")
+ 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
builder = COMP.Builder(config, logger, p_info)
# Prepare the environment
- UTS.log_step(logger, header, "PREPARE ENV")
+ UTS.log_step(logger, "PREPARE ENV")
res_prepare = builder.prepare()
- UTS.log_res_step(logger, res_prepare)
+ UTS.log_step(logger, res_prepare)
# Execute buildconfigure, configure if the product is autotools
# Execute cmake if the product is cmake
- res = 0
+ res = TODO
if not PROD.product_has_script(p_info):
- UTS.log_step(logger, header, "MAKE INSTALL")
+ UTS.log_step(logger, "MAKE INSTALL")
res_m = builder.install()
- UTS.log_res_step(logger, res_m)
+ UTS.log_step(logger, res_m)
res += res_m
-
- # Log the result
- if res > 0:
- logger.info("\r%s%s" % (header, " " * 20))
- logger.info("\r" + header + "<KO>")
- logger.debug("==== <KO> in make install of s\n" % p_name)
- else:
- logger.info("\r%s%s" % (header, " " * 20))
- logger.info("\r" + header + "<OK>")
- logger.debug("==== <OK> in make install of %s\n" % p_name)
- logger.info("\n")
return res
# Print some informations
msg = ('Executing the script in the build directories of the application %s') % \
UTS.label(config.VARS.application)
- logger.info(msg)
-
info = [(_("BUILD directory"), os.path.join(config.APPLICATION.workdir, 'BUILD'))]
- UTS.logger_info_tuples(logger, info)
+ msg += "\n" + UTS.formatTuples(info)
+ logger.trace(msg)
# Call the function that will loop over all the products and execute
# the right command(s)
if good_result == nbExpected:
status = "OK"
msg = _("Execute script")
- logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+ logger.trace("%s %s: <%s>" % (msg, msgCount, status))
else:
status = "KO"
msg = _("Problem executing script")
- logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
+ logger.warning("%s %s: <%s>" % (msg, msgCount, status))
return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
"""
p_name, p_info = p_name_info
- header = "zzzz" # TODO
# Logging
msg = _("Running script of %s ...") % UTS.label(p_name)
- logger.info(msg)
+ logger.trace(msg)
# Do nothing if he product is not compilable or has no compilation script
test1 = "properties" in p_info and \
"compilation" in p_info.properties and \
p_info.properties.compilation == "no"
if ( test1 or (not PROD.product_has_script(p_info)) ):
- UTS.log_step(logger, header, "ignored")
+ UTS.log_step(logger, "ignored")
return res.append(RCO.ReturnCode("OK", "run script %s ignored" % p_name))
builder = COMP.Builder(config, logger, p_info)
# Prepare the environment
- UTS.log_step(logger, header, "PREPARE ENV ...")
+ UTS.log_step(logger, "PREPARE ENV")
res_prepare = builder.prepare()
- UTS.log_res_step(logger, res_prepare)
+ UTS.log_step(logger, res_prepare)
# Execute the script
script_path_display = UTS.label(p_info.compil_script)
- UTS.log_step(logger, header, "SCRIPT " + script_path_display)
+ UTS.log_step(logger, "SCRIPT " + script_path_display)
res = builder.do_script_build(p_info.compil_script, number_of_proc=nb_proc)
- UTS.log_res_step(logger, res)
+ UTS.log_step(logger, res)
- #logger.info("")
-
return res
# test lrelease #.pyconf needs in ..._APPLI pre_depend : ['qt']
env = builder.build_environ.environ.environ
command = "which lrelease"
- res = UTS.Popen(command, shell=True ,env=env)
+ res = UTS.Popen(command, shell=True ,env=env, logger=logger)
if not res.isOk():
return res
# run lrelease
command = "lrelease *.ts"
cwd = str(builder.install_dir + "resources")
- res = UTS.Popen(command, shell=True, cwd=cwd, env=env)
+ res = UTS.Popen(command, shell=True, cwd=cwd, env=env, logger=logger)
return res
# clean the message color (if the terminal is redirected by user)
return replace(msg, _tagsNone)
else:
- return replace(msg, _tags)
+ # https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequences
+ # rc + CSI 0 K as clear from cursor to the end of the line
+ s = msg.replace("<RC>", "\r\033[0;K")
+ return replace(s, _tags)
def cleanColors(msg):
"""clean the message of color tags '<red> ... """
def cmake(self, options=""):
"""Runs cmake with the given options."""
+ logger = self.logger
cmake_option = options
# cmake_option +=' -DCMAKE_VERBOSE_MAKEFILE=ON -DSALOME_CMAKE_DEBUG=ON'
if 'cmake_options' in self.product_info:
print key, " ", self.build_environ.environ.environ[key]
"""
env = self.build_environ.environ.environ
- res = UTS.Popen(cmd, cwd=str(self.build_dir),env=env)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def build_configure(self, options=""):
"""Runs build_configure with the given options."""
+ logger = self.logger
if 'buildconfigure_options' in self.product_info:
options += " %s " % self.product_info.buildconfigure_options
""" % (bconf, options)
env = self.build_environ.environ.environ
- res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def configure(self, options=""):
"""Runs configure with the given options."""
+ logger = self.logger
if 'configure_options' in self.product_info:
options += " %s " % self.product_info.configure_options
""" % (conf, self.install_dir, options)
env = self.build_environ.environ.environ
- res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def hack_libtool(self):
+ logger = self.logger
libtool = os.path.join(str(self.build_dir), "libtool")
if not os.path.exists(libtool):
return RCO.ReturnCode("OK", "file libtool not existing '%s'" % libtool)
'''
env = self.build_environ.environ.environ
- res = UTS.Popen(hack_cmd, cwd=str(self.build_dir), env=env)
+ res = UTS.Popen(hack_cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def make(self, nb_proc, make_opt=""):
"""Runs make to build the module."""
# make
+ logger = self.logger
cmd = """
set -x
make -j %s %s
""" % (nb_proc, make_opt)
env = self.build_environ.environ.environ
- res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=self.logger)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def wmake(self, nb_proc, opt_nb_proc = None):
"""Runs msbuild to build the module."""
+ logger = self.logger
hh = 'MSBUILD /m:%s' % str(nb_proc)
if self.debug_mode:
hh += " " + UTS.red("DEBUG")
cmd += cmd + " ALL_BUILD.vcxproj"
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=self.logger)
+ res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=logger)
return res
def install(self):
"""Runs 'make install'."""
+ logger = self.logger
if self.config.VARS.dist_name=="Win":
cmd = "msbuild INSTALL.vcxproj"
if self.debug_mode:
cmd = 'make install'
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=self.logger)
+ res = UTS.Popen(command, cwd=str(self.build_dir), env=env, logger=logger)
return res
def check(self, command=""):
"""Runs 'make_check'."""
+ logger = self.logger
if ARCH.is_windows():
cmd = "msbuild RUN_TESTS.vcxproj"
else :
cmd = command
env = self.build_environ.environ.environ
- res = UTS.Popen(command, cwd=str(self.build_dir), env=env , logger=self.logger)
+ res = UTS.Popen(command, cwd=str(self.build_dir), env=env , logger=logger)
return res
self.build_environ.set("VERSION", self.product_info.version)
def do_batch_script_build(self, script, nb_proc):
-
+ logger = self.logger
if ARCH.is_windows():
make_options = "/maxcpucount:%s" % nb_proc
else :
make_options = "-j%s" % nb_proc
- self.logger.trace(_("Run build script '%s'") % script)
+ self.logger.trace(_("Run build script %s") % UTS.label(script))
self.complete_environment(make_options)
# linux or win compatible, have to be chmod +x ?
""" % script
env = self.build_environ.environ.environ
- res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env)
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env, logger=logger)
return res
def do_script_build(self, script, number_of_proc=0):
_KOSYS = 1 # avoid import src
+# Compatibility python 2/3 for input function
+# input stays input for python 3 and input = raw_input for python 2
+try:
+ input = raw_input
+except NameError:
+ pass
+
########################################################################
# NO __main__ entry allowed, use sat
########################################################################
env["PATH"] = rootdir + ":" + env["PATH"]
# TODO setLocale not 'fr' on subprocesses, why not?
# env["LANG"] == ''
- res = UTS.Popen(command, env=env)
+ res = UTS.Popen(command, env=env, logger=None) # no logger!
return res
def setNotLocale():
self.nameAppliLoaded = None
self.parser = self._getParser()
+ self._confirmMode = True
def __repr__(self):
aDict = {
return msg
def getConfirmMode(self):
- return False
+ return self._confirmMode
+
+ def setConfirmMode(self, value):
+ self._confirmMode = value
def getBatchMode(self):
- return True
+ return self.options.batch
def getAnswer(self, msg):
"""
- question and user answer (in console) if confirm mode and not batch mode
- returns 'YES' or 'NO' if confirm mode and not batch mode
- returns 'YES' if batch mode
+ question and user answer (in console)
+ if confirm mode and not batch mode.
+
+ | returns 'YES' or 'NO' if confirm mode and not batch mode
+ | returns 'YES' if batch mode
"""
+ logger = self.getLogger()
if self.getConfirmMode() and not self.getBatchMode():
- self.getLogger().info(msg)
- rep = input(_("Are you sure you want to continue? [yes/no]"))
+ logger.info("\n" + msg)
+ rep = input(_("Do you want to continue? [yes/no] "))
if rep.upper() == _("YES"):
return "YES"
else:
return "NO"
else:
- self.getLogger().info(msg)
- self.getLogger().info("<green>YES<reset> (as automatic answer)")
+ logger.debug(msg) # silent message
+ logger.debug("<green>YES<reset> (as automatic answer)")
return "YES"
msg = formatTuples(tuples)
logger.info(msg)
-def log_step(logger, header, step):
- #logger.info("\r%s%s" % (header, step))
- logger.info("%s" % step)
-
-def log_res_step(logger, res):
- if res.isOk():
- logger.info("<OK>")
+_log_step_header = ["No log step header ..."]
+
+def init_log_step(logger, header, step=""):
+ _log_step_header.append(header)
+ log_step(logger, step)
+
+def log_step(logger, step):
+ header = _log_step_header[-1]
+ if type(step) == str:
+ 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()))
+
+def end_log_step(logger, step):
+ header = _log_step_header[-1]
+ if type(step) == str:
+ logger.info("<RC>%s%s" % (header, step))
+ if len(_log_step_header) > 1: _log_step_header.pop()
+ return
+ #as ReturnCode type
+ if step.isOk():
+ logger.info("<RC>%s <OK>" % header)
else:
- logger.info("<KO>")
+ logger.info("<RC>%s <%s>" % (header, step.getStatus()))
+ if len(_log_step_header) > 1: _log_step_header.pop()
+
def isSilent(output_verbose_level):
"""is silent fort self.build_environ"""
if logger is not None:
logger.trace("<OK> launch command rc=%s cwd=<info>%s<reset>:\n%s" % (rc, cwd, command))
logger.trace("<OK> result command stdout&stderr:\n%s" % res_out)
- return RCO.ReturnCode("OK", "command done", value=res_out)
+ return RCO.ReturnCode("OK", "Popen command done", value=res_out)
else:
if logger is not None:
logger.warning("<KO> launch command rc=%s cwd=<info>%s<reset>:\n%s" % (rc, cwd, command))
logger.warning("<KO> result command stdout&stderr:\n%s" % res_out)
- return RCO.ReturnCode("KO", "command problem", value=res_out)
+ return RCO.ReturnCode("KO", "Popen command problem", value=res_out)
else: #except Exception as e:
logger.error("<KO> launch command cwd=%s:\n%s" % (cwd, command))
logger.error("launch command exception:\n%s" % e)
- return RCO.ReturnCode("KO", "launch command problem")
+ return RCO.ReturnCode("KO", "Popen command problem")
def generate_catalog(machines, config, logger):
logger.info(" ssh %s " % (k + " ").ljust(20, '.'), 4)
ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
- res = UTS.Popen(ssh_cmd, shell=True)
+ res = UTS.Popen(ssh_cmd, shell=True, logger=logger)
if res.isOk():
lines = p.stdout.readlines()
freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
<xsl:variable name="txtLog">
<xsl:value-of select="SATcommand/OutLog"/>
</xsl:variable>
- <iframe src="{$txtLog}" frameborder="0" class="center" width="98%" height="1000" scrolling="yes"></iframe>
- <!--<iframe src="{$txtLog}" frameborder="0" class="center" width="98%" height="1000" scrolling="yes"></iframe>-->
+ <iframe src="{$txtLog}" frameborder="0" class="center" width="98%" height="600" scrolling="yes"></iframe>
+ <!--<iframe src="{$txtLog}" frameborder="0" class="center" width="98%" height="600" scrolling="yes"></iframe>-->
</body>
</xsl:template>