msg = _("Application %s, executing compile commands in build directories of products.\n")
logger.info(msg % UTS.label(nameApp))
- info = [ (_("SOURCE directory"), srcDir),
- (_("BUILD directory"),buildDir) ]
+ info = [ (_("SOURCE directory"), UTS.info(srcDir)),
+ (_("BUILD directory"), UTS.info(buildDir)) ]
UTS.logger_info_tuples(logger, info)
# Get the list of products to treat
# Sort the list regarding the dependencies of the products
products_infos = sort_products(config, products_infos)
-
# Call the function that will loop over all the products and execute
# the right command(s)
# Print the final state
nb_products = len(products_infos)
- if res == 0:
- final_status = "<OK>"
- else:
- final_status = "<KO>"
-
- logger.info(_("\nCompilation: %(status)s (%(1)d/%(2)d)\n") % \
- { 'status': final_status,
- '1': nb_products - res,
- '2': nb_products })
+ nb_ok = res.getValue()
+
+ logger.info(_("\nCompilation: <%(0)s> (%(1)d/%(2)d)\n") % \
+ { '0': res.getStatus(),
+ '1': nb_products - nb_ok,
+ '2': nb_products } )
- code = res
- if code != 0:
- code = 1
- return code
+ return res
def get_children(config, p_name_p_info):
l_res = []
if father_name not in l_fathers_name:
if father_name not in config.APPLICATION.products:
msg = _("The product %(father_name)s that is in %(product_nam"
- "e)s dependencies is not present in application "
- "%(appli_name)s" % {"father_name" : father_name,
- "product_name" : p_name,
- "appli_name" : config.VARS.application})
+ "e)s dependencies is not present in application %(appli_name)s" % \
+ {"father_name" : father_name,
+ "product_name" : p_name,
+ "appli_name" : config.VARS.application})
raise Exception(msg)
prod_info_father = PROD.get_product_config(config, father_name)
pname_pinfo_father = (prod_info_father.name, prod_info_father)
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: (RCO.ReturnCode) with value as the number of failing commands.
"""
res = 0
for p_name_info in products_infos:
# 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"):
-
+ p_info.properties.compilation == "no"):
UTS.log_step(logger, header, "ignored")
- logger.info("\n")
continue
# Do nothing if the product is native
if PROD.product_is_native(p_info):
UTS.log_step(logger, header, "native")
- logger.info("\n")
continue
# Clean the build and the install directories
# Check if it was already successfully installed
if PROD.check_installation(p_info):
- logger.info(_("Already installed\n"))
+ logger.info(_("Already installed"))
continue
# If the show option was called, do not launch the compilation
if options.no_compile:
- logger.info(_("Not installed\n"))
+ logger.info(_("Not installed"))
continue
# Check if the dependencies are installed
logger.info("\r" + header + "<OK>")
logger.info(_("\nINSTALL directory = %s") % p_info.install_dir)
logger.debug("\n==== <OK> in compile of %s\n" % p_name)
- logger.info("\n")
if res_prod != 0 and options.stop_first_fail:
break
- return res
+ if res == 0: # no failing commands
+ return RCO.ReturnCode("OK", "no failing compile commands", res)
+ else:
+ return RCO.ReturnCode("KO", "existing %i failing compile commands" % res, res)
def compile_product(sat, p_name_info, config, options, logger, header, len_end):
"""
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.
"""
p_name, p_info = p_name_info
# Check that the install directory exists
if res==0 and not(os.path.exists(p_info.install_dir)):
- res = 1
error_step = "NO INSTALL DIR"
- msg = _("despite all the steps ended successfully, no install directory was found\n")
+ msg = _("All steps ended successfully, but install directory not found")
logger.error(msg)
- return res, len_end, error_step
+ return RCO.ReturnCode("KO", "Install directory not found", (error_step, p_name, p_info.install_dir))
# Add the config file corresponding to the dependencies/versions of the
# product that have been successfully compiled
VersionSalome = UTS.get_salome_version(config)
if VersionSalome >= 750 :
use_autotools=False
- builder.log('USE CMAKE', 3)
+ logger.info('USE CMAKE')
else:
use_autotools=True
- builder.log('USE AUTOTOOLS', 3)
+ logger.info('USE AUTOTOOLS')
result = "GENERATE"
- builder.log('GENERATE', 3)
+ logger.info('GENERATE')
prevstdout = sys.stdout
prevstderr = sys.stderr
if use_autotools:
result = "BUID_CONFIGURE"
- builder.log('BUID_CONFIGURE (no bootstrap)', 3)
+ logger.info('BUID_CONFIGURE (no bootstrap)')
g.bootstrap(compo_info.source_dir, logger.logTxtFile)
result = RCO._OK_STATUS
# write results
msg = ("Patching sources of the application: <%s> (%d/%d)") % \
(status, good_result, len(products_infos))
- logger.info(msg)
+ logger.info("\n" + msg)
+
+ msg = ("Patching sources of the application (%d/%d)") % \
+ (good_result, len(products_infos))
+
return RCO.ReturnCode(status, msg)
-
def apply_patch(config, product_info, max_product_name_len, logger):
"""The method called to apply patches on a product
import os
import re
+import pprint as PP
import src.debug as DBG
import src.returnCode as RCO
def run(self, cmd_arguments):
"""method called for command 'sat prepare <options>'"""
argList = self.assumeAsList(cmd_arguments)
-
- # print general help and returns
- if len(argList) == 0:
- self.print_help()
- return RCO.ReturnCode("OK", "No arguments, as 'sat %s --help'" % self.name)
-
+
self._options, remaindersArgs = self.parseArguments(argList)
if self._options.help:
args_appli = config.VARS.application
if options.products:
listProd = list(options.products)
- else:
+ else: # no product interpeted as all products
listProd = [name for name, tmp in products_infos]
+ logger.warning("prepare all products:\n%s" % PP.pformat(sorted(listProd)))
+
+ # DBG.write("prepare products", sorted(listProd))
args_product_opt = '--products ' + ",".join(listProd)
do_source = (len(listProd) > 0)
import os
import shutil
+import pprint as PP
import src.debug as DBG
import src.returnCode as RCO
else:
status = "KO"
msg = _("Some sources haven't been get")
- details = [p for p in results if (results[product] == 0 or results[product] is None)]
- details = ",".join(details)
- logger.info("\n%s %s: <%s>.\n%s\n" % (msg, msgCount, status, details))
+ logger.info("\n%s %s: <%s>.\n" % (msg, msgCount, status))
- return RCO.ReturnCode(status, "%s get sources: %s" % (msg, msgCount))
+ return RCO.ReturnCode(status, "%s %s" % (msg, msgCount))
def get_source_for_dev(config, product_info, source_dir, logger, pad):
:param logger: (Logger)
The logger instance to use for the display and logging
:param pad: (int) The gap to apply for the terminal display
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
# Call the function corresponding to get the sources with True checkout
:param is_dev: (bool) True if the product is in development mode
:param environ: (src.environment.Environ)
The environment to source when extracting.
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
# The str to display
coflag = 'git'
where to put the sources
:param logger: (Logger)
The logger instance to use for the display and logging
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
# check archive exists
archName = product_info.archive_info.archive_name
def get_source_from_dir(product_info, source_dir, logger):
if "dir_info" not in product_info:
- msg = _("You must put a dir_info section in the file %s.pyconf") % \
- product_info.name
+ msg = _("You must put a dir_info section in the file %s.pyconf") % product_info.name
logger.error(msg)
- return False
+ return RCO.ReturnCode("KO", msg)
if "dir" not in product_info.dir_info:
msg = _("Error: you must put a dir in the dir_info section in the file %s.pyconf") % \
product_info.name
logger.error(msg)
- return False
+ return RCO.ReturnCode("KO", msg)
# check that source exists
if not os.path.exists(product_info.dir_info.dir):
msg = _("The dir %s defined in the file %s.pyconf does not exists") % \
(product_info.dir_info.dir, product_info.name)
logger.error(msg)
- return False
+ return RCO.ReturnCode("KO", msg)
logger.info(' DIR: %s ...' % UTS.info(product_info.dir_info.dir))
retcode = UTS.Path(product_info.dir_info.dir).copy(source_dir)
- return retcode
+ if retcode:
+ RCO.ReturnCode("OK", "for copy directory s'" % product_info.dir_info.dir)
+ else:
+ RCO.ReturnCode("KO", "for copy directory s'" % product_info.dir_info.dir)
def get_source_from_cvs(user,
product_info,
:param pad: (int) The gap to apply for the terminal display
:param environ: (src.environment.Environ)
The environment to source when extracting.
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
# Get the protocol to use in the command
if "protocol" in product_info.cvs_info:
product_info.cvs_info.product_base)
coflag = 'cvs'
- if checkout: coflag = coflag.upper()
+ if checkout:
+ coflag = coflag.upper()
msg = " %s:%s" % (coflag, cvs_line)
msg += " src:%s" % product_info.cvs_info.source
logger.info(msg)
# Call the system function that do the extraction in cvs mode
retcode = SYSS.cvs_extract(protocol, user,
- product_info.cvs_info.server,
- product_info.cvs_info.product_base,
- product_info.cvs_info.tag,
- product_info.cvs_info.source,
- source_dir, logger, checkout, environ)
+ product_info.cvs_info.server,
+ product_info.cvs_info.product_base,
+ product_info.cvs_info.tag,
+ product_info.cvs_info.source,
+ source_dir, logger, checkout, environ)
return retcode
def get_source_from_svn(user,
The logger instance to use for the display and logging
:param environ: (src.environment.Environ)
The environment to source when extracting.
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
coflag = 'svn'
if checkout: coflag = coflag.upper()
The logger instance to use for the display and logging
:param pad: (int) The gap to apply for the terminal display
:param checkout: (bool) If True, get the source in checkout mode
- :return: (bool) True if it succeed, else False
+ :return: (RCO.ReturnCode) OK if it succeed
"""
# Get the application environment
if product_info.get_source == "native":
# skip
- msg = "<OK>" + _("\ndo nothing because the product is of type 'native'.\n")
- logger.info(msg)
- return True
+ msg = _("Do nothing because the product is of type 'native'")
+ logger.info("<OK> " + msg)
+ return RCO.ReturnCode("OK", msg)
if product_info.get_source == "fixed":
# skip
- msg = "<OK>" + _("\ndo nothing because the product is of type 'fixed'.\n")
- logger.info(msg)
- return True
+ msg = _("Do nothing because the product is of type 'fixed'")
+ logger.info("<OK> " + msg)
+ return RCO.ReturnCode("OK", msg)
# if the get_source is not in [git, archive, cvs, svn, fixed, native]
msg = _("Unknown get source method '%s' for product %s") % \
( product_info.get_source, product_info.name)
- logger.info("%s ... " % msg)
- return False
+ logger.warning("<KO> " + msg)
+ return RCO.ReturnCode("KO", msg)
def get_all_product_sources(config, products, logger):
"""Get all the product sources.
if source_dir.exists():
msg = _("Do nothing because source directory existing yet.")
logger.warning(msg)
- logger.info("<OK>")
+ logger.info("<OK> "+ msg)
good_result = good_result + 1
# Do not get the sources and go to next product
continue
# Check that the sources are correctly get using the files to be tested
# in product information
- if retcode:
+ if retcode.isOk():
rc = check_sources(product_info, logger)
if not rc.isOk():
# Print the missing file path
# show results
results[product_name] = retcode
- if retcode:
+ if retcode.isOk():
# The case where it succeed
res = "<OK>"
good_result = good_result + 1
else:
logger.debug("%s <OK>" % msg)
if len(filesKo) != 0:
- return RCO.ReturnCode("KO", "check_sources, missing files")
+ return RCO.ReturnCode("KO", "check_sources, missing files", filesKo)
else:
- return RCO.ReturnCode("OK", "check_sources, no missing file")
+ return RCO.ReturnCode("OK", "check_sources, no missing file", l_files_to_be_tested)
{
project_file_paths :
[
- "/home/christian/SAT_SALOME/salome.pyconf"
- "/home/christian/SAT_MATIX/matix.pyconf"
+ "/volatile/wambeke/SAT5/SAT5_S840_MATIX24/SAT_SALOME/salome.pyconf",
+ # "/home/uranietm/proJET/saTJOBS/saT5/uranie.pyconf",
+ # cloned 2017/12 for matix
+ # "/home/matix/GitRepo/uranie/saT5/uranie.pyconf",
+ # "/volatile/wambeke/SAT5/SAT_MATIX/matix.pyconf"
]
}
try:
returnCode = sat.execute_cli(args)
- DBG.write("execute_cli return code", returnCode)
- if returnCode.isOk():
- logger.debug("sat exit code: %s" % returnCode) # OK no trace
- else:
- # warning as known problem
- logger.warning("<red>sat exit code: %s<reset>" % returnCode) # KO have to say why
- logger.close()
- sys.exit(returnCode.toSys())
-
except Exception as e:
# error as may be unknown problem
# verbose debug message with traceback if developers
msg = "Exception raised for execute_cli (%s):\n" % " ".join(args)
logger.critical(DBG.format_color_exception(msg))
- logger.close()
+ logger.close() # important to close logger
sys.exit(KOSYS)
+ # no Exception but may be known problem
+ DBG.write("execute_cli return code", returnCode)
+ if returnCode.isOk():
+ # OK no trace
+ logger.debug("sat exit code: %s" % returnCode)
+ else:
+ # KO warning as known problem have to say why
+ logger.warning("<red>sat exit code: %s<reset>" % returnCode)
+ logger.close() # important to close logger
+ sys.exit(returnCode.toSys())
+
+
else:
logger.critical("forbidden/unexpected mode for __name__ '%s'" % __name__)
- logger.close()
+ logger.close() # important to close logger
sys.exit(KOSYS)
import subprocess as SP
from src.options import OptResult
+import returnCode as RCO
import src.utilsSat as UTS
import src.product as PROD
import src.environment as ENVI
if "debug" in self.product_info and self.product_info.debug == "yes":
self.debug_mode = True
- def log(self, text, level, showInfo=True):
- """Shortcut method to log in log file."""
- self.logger.info(text)
- self.logger.logTxtFile.write(UTS.cleancolor(text))
-
- def log_command(self, command):
- """Shortcut method to log a command."""
- self.log("> %s\n" % command, 5)
-
def prepare(self):
"""
Prepares the environment.
# create build environment
self.build_environ = ENVI.SalomeEnviron(self.config, ENVI.Environ(dict(os.environ)), True)
- self.build_environ.silent = (self.config.USER.output_verbose_level < 5)
+ self.build_environ.silent = UTS.isSilent(self.config.USER.output_verbose_level)
self.build_environ.set_full_environ(self.logger, environ_info)
# create runtime environment
return 0
-
def cmake(self, options=""):
"""Runs cmake with the given options."""
cmake_option = options
cmake_option += " -DCMAKE_GENERATOR=%s" \
% self.config.APPLICATION.cmake_generator
- command = ("cmake %s -DCMAKE_INSTALL_PREFIX=%s %s" %
- (cmake_option, self.install_dir, self.source_dir))
-
- self.log_command(command)
- # for key in sorted(self.build_environ.environ.environ.keys()):
- # print key, " ", self.build_environ.environ.environ[key]
- res = SP.call(command, shell=True, cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
-
- self.put_txt_log_in_appli_log_dir("cmake")
- if res == 0:
- return res
- else:
- return 1
+ cmd = """
+# CMAKE
+set -x
+cmake %s -DCMAKE_INSTALL_PREFIX=%s %s
+""" % (cmake_option, self.install_dir, self.source_dir)
+
+ """
+ for key in sorted(self.build_environ.environ.environ.keys()):
+ 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)
+ return res
def build_configure(self, options=""):
if 'buildconfigure_options' in self.product_info:
options += " %s " % self.product_info.buildconfigure_options
- command = str('%s/build_configure') % (self.source_dir)
- command = command + " " + options
- self.log_command(command)
-
- res = SP.call(command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
- self.put_txt_log_in_appli_log_dir("build_configure")
- if res == 0:
- return res
- else:
- return 1
+ bconf = os.path.join(self.source_dir, "build_configure")
+ cmd = """
+set -x
+%s %s
+""" % (bconf, options)
+
+ env = self.build_environ.environ.environ
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env)
+ return res
def configure(self, options=""):
if 'configure_options' in self.product_info:
options += " %s " % self.product_info.configure_options
- command = "%s/configure --prefix=%s" % (self.source_dir,
- str(self.install_dir))
-
- command = command + " " + options
- self.log_command(command)
+ conf = os.path.join(self.source_dir, "configure")
+ cmd = """
+set -x
+%s --prefix=%s %s
+""" % (conf, self.install_dir, options)
- res = SP.call(command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
-
- self.put_txt_log_in_appli_log_dir("configure")
- if res == 0:
- return res
- else:
- return 1
+ env = self.build_environ.environ.environ
+ res = UTS.Popen(cmd, cwd=str(self.build_dir), env=env)
+ return res
def hack_libtool(self):
- if not os.path.exists(str(self.build_dir + 'libtool')):
- return
+ 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)
- lf = open(os.path.join(str(self.build_dir), "libtool"), 'r')
- for line in lf.readlines():
+ with open(libtool, 'r') as lf:
+ for line in lf.readlines():
if 'hack_libtool' in line:
- return
+ return RCO.ReturnCode("OK", "existing 'hack_libtool' in '%s'" % libtool)
# fix libtool by replacing CC="<compil>" with hack_libtool function
- hack_command='''sed -i "s%^CC=\\"\(.*\)\\"%hack_libtool() { \\n\\
+ # TODO rewrite that horreur
+ obsolete_hack_cmd='''
+set -x
+sed -i "s%^CC=\\"\(.*\)\\"%hack_libtool() { \\n\\
if test \\"\$(echo \$@ | grep -E '\\\\\\-L/usr/lib(/../lib)?(64)? ')\\" == \\\"\\\" \\n\\
then\\n\\
cmd=\\"\\1 \$@\\"\\n\\
}\\n\\
CC=\\"hack_libtool\\"%g" libtool'''
- self.log_command(hack_command)
- SP.call(hack_command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
+ hack_cmd=r'''
+set -x
+sed -i "s%^CC=\"\(.*\)\"%hack_libtool() { \n\
+if test \"\$(echo \$@ | grep -E '\\\-L/usr/lib(/../lib)?(64)? ')\" == \"\" \n\
+ then\n\
+ cmd=\"\1 \$@\"\n\
+ else\n\
+ cmd=\"\1 \"\`echo \$@ | sed -r -e 's|(.*)-L/usr/lib(/../lib)?(64)? (.*)|\\\1\\\4 -L/usr/lib\\\3|g'\`\n\
+ fi\n\
+ \$cmd\n\
+}\n\
+CC=\"hack_libtool\"%g" libtool
+'''
+
+ env = self.build_environ.environ.environ
+ res = UTS.Popen(hack_cmd, cwd=str(self.build_dir), env=env)
+ return res
- ##
- # Runs make to build the module.
def make(self, nb_proc, make_opt=""):
-
+ """Runs make to build the module."""
# make
- command = 'make'
- command = command + " -j" + str(nb_proc)
- command = command + " " + make_opt
- self.log_command(command)
- res = SP.call(command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
- self.put_txt_log_in_appli_log_dir("make")
- if res == 0:
- return res
- else:
- return 1
+ cmd = """
+set -x
+make -j %s %s
+""" % (nb_proc, make_opt)
+
+ env = self.build_environ.environ.environ
+ res = SP.call(cmd, cwd=str(self.build_dir), env=env)
+ return res
+
- def wmake(self,nb_proc, opt_nb_proc = None):
+ def wmake(self, nb_proc, opt_nb_proc = None):
"""Runs msbuild to build the module."""
hh = 'MSBUILD /m:%s' % str(nb_proc)
if self.debug_mode:
hh += " " + UTS.red("DEBUG")
# make
- command = 'msbuild'
- command = command + " /maxcpucount:" + str(nb_proc)
+ cmd = "msbuild /maxcpucount:%s" % nb_proc
if self.debug_mode:
- command = command + " /p:Configuration=Debug"
+ cmd += " /p:Configuration=Debug"
else:
- command = command + " /p:Configuration=Release"
- command = command + " ALL_BUILD.vcxproj"
-
- self.log_command(command)
- res = SP.call(command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
-
- self.put_txt_log_in_appli_log_dir("make")
- if res == 0:
- return res
- else:
- return 1
+ cmd += " /p:Configuration=Release"
+ cmd += cmd + " ALL_BUILD.vcxproj"
+ env = self.build_environ.environ.environ
+ res = SP.Popen(command, cwd=str(self.build_dir), env=env)
+ return res
+
def install(self):
"""Runs 'make install'."""
if self.config.VARS.dist_name=="Win":
- command = 'msbuild INSTALL.vcxproj'
+ cmd = "msbuild INSTALL.vcxproj"
if self.debug_mode:
- command = command + " /p:Configuration=Debug"
+ cmd += " /p:Configuration=Debug"
else:
- command = command + " /p:Configuration=Release"
+ cmd += " /p:Configuration=Release"
else :
- command = 'make install'
-
- self.log_command(command)
-
- res = SP.call(command,
- shell=True,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
-
- self.put_txt_log_in_appli_log_dir("makeinstall")
- if res == 0:
- return res
- else:
- return 1
+ cmd = 'make install'
+ env = self.build_environ.environ.environ
+ res = SP.Popen(command, cwd=str(self.build_dir), env=env)
+ return res
def check(self, command=""):
"""Runs 'make_check'."""
if ARCH.is_windows():
- cmd = 'msbuild RUN_TESTS.vcxproj'
+ cmd = "msbuild RUN_TESTS.vcxproj"
else :
if self.product_info.build_source=="autotools" :
cmd = 'make check'
if command:
cmd = command
- self.log_command(cmd)
-
- res = SP.call(cmd,
- shell=True,
- cwd=str(self.build_dir),
- env=self.launch_environ.environ.environ,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT)
+ env = self.build_environ.environ.environ
+ res = SP.Popen(command, cwd=str(self.build_dir), env=env)
+ return res
- if res == 0:
- return res
- else:
- return 1
def do_default_build(self,
build_conf_options="",
else :
make_options = "-j%s" % nb_proc
- self.log_command(" " + _("Run build script %s\n") % script)
+ self.logger.info(_("Run build script '%s'") % script)
self.complete_environment(make_options)
- res = SP.call(script,
- shell=True,
- stdout=self.logger.logTxtFile,
- stderr=SP.STDOUT,
- cwd=str(self.build_dir),
- env=self.build_environ.environ.environ)
-
- self.put_txt_log_in_appli_log_dir("script")
- if res == 0:
- return res
- else:
- return 1
+ # linux or win compatible, have to be chmod +x ?
+ cmd = """
+# Run build script
+%s
+""" % script
+
+
+ env = self.build_environ.environ.environ
+ res = SP.Popen(cmd, cwd=str(self.build_dir), env=env)
+ return res
def do_script_build(self, script, number_of_proc=0):
# define make options (may not be used by the script)
else:
nb_proc = min(number_of_proc, self.config.VARS.nb_proc)
- extension = script.split('.')[-1]
- if extension in ["bat","sh"]:
+ extension = os.path.splitext(script)[-1]
+ if extension in [".bat", ".sh", ".bash"]:
return self.do_batch_script_build(script, nb_proc)
- if extension == "py":
+ if extension == ".py":
return self.do_python_script_build(script, nb_proc)
- msg = _("The script %s must have .sh, .bat or .py extension.") % script
+ msg = _("The script %s must have extension as .sh, .bat or .py.") % script
raise Exception(msg)
-
- def put_txt_log_in_appli_log_dir(self, file_name):
- """
- Put the txt log (that contain the system logs, like make command output)
- in the directory <APPLICATION DIR>/LOGS/<product_name>/
-
- :param file_name: (str) The name of the file to write
- """
- if self.logger.logTxtFile == sys.__stdout__:
- return
- dir_where_to_put = os.path.join(self.config.APPLICATION.workdir, "LOGS", self.product_info.name)
- file_path = os.path.join(dir_where_to_put, file_name)
- UTS.ensure_path_exists(dir_where_to_put)
- # write the logTxtFile copy it to the destination, and then recreate
- # it as it was
- self.logger.logTxtFile.close()
- shutil.move(self.logger.txtFilePath, file_path)
- self.logger.logTxtFile = open(str(self.logger.txtFilePath), 'w')
- self.logger.logTxtFile.write(open(file_path, "r").read())
"""
# get the expected name and path of the file
self.config_file_name = 'SAT.pyconf'
- self.user_config_file_path = os.path.join(config.VARS.personalDir,
- self.config_file_name)
+ cfg_name = os.path.join(config.VARS.personalDir, self.config_file_name)
+ self.user_config_file_path = cfg_name
# if pyconf does not exist, create it from scratch
- if not os.path.isfile(self.user_config_file_path):
+ DBG.write("user config file", cfg_name)
+ if not os.path.isfile(cfg_name):
self.create_config_file(config)
def create_config_file(self, config):
"This is the user name used to access salome cvs base.\n")
USER.addMapping('svn_user', config.VARS.user,
"This is the user name used to access salome svn base.\n")
- USER.addMapping('output_verbose_level', 3,
- "This is the default output_verbose_level you want. 0=>no output, 5=>debug.\n")
+ # TODO set output_verbose_level sat5.1 as "CRITICAL->DEBUG" but not sat5.0 "0->5"
+ USER.addMapping('output_verbose_level', "3",
+ "This is the default sat5 output_verbose_level you want. 0=>warning, 3=>info, 5=>debug.\n")
USER.addMapping('publish_dir', os.path.join(os.path.expanduser('~'), 'websupport', 'satreport'),
"")
USER.addMapping('editor', 'vi', "This is the editor used to modify configuration files\n")
UTS.ensure_path_exists(config.VARS.personalDir)
UTS.ensure_path_exists(os.path.join(config.VARS.personalDir, 'Applications'))
-
+
+ self.logger.warning("Create user config file %s" % UTS.info(cfg_name))
with open(cfg_name, 'w') as f:
cfg.__save__(f)
return cfg
batch_save = self.options.batch
self.options.__setattr__("batch", True)
- # set output level
+ # set output level, TODO useless sat5.1?
if self.runner.options.output_verbose_level is not None:
config.USER.output_verbose_level = self.runner.options.output_verbose_level
- if config.USER.output_verbose_level < 1:
- config.USER.output_verbose_level = 0
- silent = (config.USER.output_verbose_level == 0)
+ silent = config.USER.output_verbose_level in ["WARNING", "ERROR", "CRITICAL"]
# create log file
micro_command = False
# todo etc
self.isClosed = True # done at end sat, flushed closed xml files.
return
-
+
def __repr__(self):
"""one line string representation"""
msg = "%s(name=%s, dateLogger=%s, handlers=%s)"
in code of all salomeTools commands
The aim of this class is to have an elegant syntax to manipulate the options.
- | Example:
+ | Example:
+ | >> options, remainderArgs = command.parseArguments(args)
| >> print(options.output_verbose_level)
| >> 'INFO'
"""
self._value = value
else:
self._value = self._DEFAULT_VALUE
+
+ def getStatus(self):
+ return self._status
def isOk(self):
"""
LKXML.setAttribLinkForCommand(cmdInstance, "full_launched_cmd", strArgs)
LKXML.setAttribLinkForCommand(cmdInstance, "cmd_res", returnCode.toXmlPassed())
- logger.closeFileHandlerForCommand(cmdInstance)
+ # close logger/main handler have to be caller stuff...
return returnCode
else:
logger.info("<KO>\n")
+def isSilent(output_verbose_level):
+ """is silent fort self.build_environ"""
+ lev = levelToSat5p1(output_verbose_level)
+ if lev in ["TRACE", "DEBUG"]:
+ return False # as verbose if debug
+ return True # as silent if not debug
+
+def levelToSat5p1(output_verbose_level):
+ """
+ convert sat5 output_verbose_level integer 0=>no output, 5=>debug
+ to string sat5.1 compatible ('INFO', 'DEBUG' etc)
+ """
+ try:
+ aInt = int(output_verbose_level)
+ if aInt < 0: return "INFO" # not set
+ if aInt < 3: return "WARNING"
+ if aInt == 3: return "INFO"
+ if aInt == 4: return "TRACE"
+ return "DEBUG"
+ except:
+ return str(output_verbose_level) # suppose sat5.1 'DEBUG' to 'CRITICAL'
+
##############################################################################
# color utilities, for convenience
##############################################################################