#Save previous version
pyconf = config.VARS.product + '.pyconf'
pyconfBackup = config.VARS.product + '-backup.pyconf'
- logger.write(
- _("Updating %(new)s (previous version saved as %(old)s)." ) % \
- { "new": pyconf, "old": pyconfBackup }, 3)
+ logger.info( _("Updating %s (previous version saved as %s." ) % (pyconf, pyconfBackup)
path = config.getPath( pyconf )
shutil.copyfile( os.path.join( path, pyconf ),
os.path.join( path, pyconfBackup ) )
+++ /dev/null
-../../../../src/custom.css
\ No newline at end of file
--- /dev/null
+/* This file is for theme alabaster custom. */
+
+/*
+http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
+set backquotes: ``text`` for code samples more color red
+*/
+tt, code {
+ background-color: #ecf0f3;
+ color: #842;
+ /* padding: 1px 2px; */
+}
+
+/*
+set 'Note:' etc size less than titles
+*/
+div.admonition p.admonition-title {
+ font-family: {{ theme_head_font_family }};
+ font-weight: normal;
+ font-size: 16px;
+ margin: 0 0 10px 0;
+ padding: 0;
+ line-height: 1;
+}
+
+
Basic requirements
==================
-.. warning :: THIS IS OBSOLETE FOR SAT 5.1
+.. warning:: ALL THIS IS OBSOLETE FOR SAT 5.1
By adding a file *mycommand.py* in the ``commands`` directory, salomeTools will define a new command named ``mycommand``.
HowTo logger
==============
-The logger variable is an instance of the Logger class.
-It gives access to the write method.
+The logger variable is an instance of the python ``logging`` package class.
+It gives access to ``debug, info, warning, error, critical`` methods.
-When this method is called, the message passed as parameter
+Using these methods, the message passed as parameter
will be displayed in the terminal and written in an xml log file.
.. code-block:: python
- logger.write("My message", 3) # 3 as default
+ logger.info("My message")
-The second argument defines the level of verbosity
-that is wanted for this message.
-It has to be between 1 and 5 (the most verbose level).
HELLO example
==============
self.python_lib1 = self.get('PYTHON_LIBDIR1')
def get_names(self, lProducts):
- """Get the products name to add in SALOME_MODULES environment variable
- It is the name of the product, except in the case where the is a
- component name. And it has to be in SALOME_MODULES variable only
- if the product has the property has_salome_hui = "yes"
+ """\
+ Get the products name to add in SALOME_MODULES environment variable
+ It is the name of the product, except in the case where the is a
+ component name. And it has to be in SALOME_MODULES variable only
+ if the product has the property has_salome_hui = "yes"
:param lProducts list: List of products to potentially add
"""
self.add_line(1)
def set_salome_minimal_product_env(self, product_info, logger):
- """Sets the minimal environment for a SALOME product.
- xxx_ROOT_DIR and xxx_SRC_DIR
+ """\
+ Sets the minimal environment for a SALOME product.
+ xxx_ROOT_DIR and xxx_SRC_DIR
:param product_info Config: The product description
:param logger Logger: The logger instance to display messages
if 'install_dir' in product_info and product_info.install_dir:
self.set(root_dir, product_info.install_dir)
elif not self.silent:
- logger.write(" " + _("No install_dir for product %s\n") %
- product_info.name, 5)
+ logger.warning(_("No install_dir for product %s\n") % product_info.name)
- source_in_package = src.get_property_in_product_cfg(product_info,
- "sources_in_package")
+ source_in_package = src.get_property_in_product_cfg(product_info, "sources_in_package")
if not self.for_package or source_in_package == "yes":
# set source dir, unless no source dir
if not src.product.product_is_fixed(product_info):
if not self.for_package:
self.set(src_dir, product_info.source_dir)
else:
- self.set(src_dir, os.path.join("out_dir_Path",
- "SOURCES",
- product_info.name))
+ srcDir = os.path.join("out_dir_Path", "SOURCES", product_info.name)
+ self.set(src_dir, srcDir)
def set_salome_generic_product_env(self, pi):
"""Sets the generic environment for a SALOME product.
pi = src.product.get_product_config(self.cfg, product)
if self.for_package:
- pi.install_dir = os.path.join("out_dir_Path",
- self.for_package,
- pi.name)
+ pi.install_dir = os.path.join("out_dir_Path", self.for_package, pi.name)
if not self.silent:
- logger.write(_("Setting environment for %s\n") % product, 4)
+ logger.info(_("Setting environment for %s\n") % product)
self.add_line(1)
self.add_comment('setting environ for ' + product)
def run_env_script(self, product_info, logger=None, native=False):
- """Runs an environment script.
+ """\
+ Runs an environment script.
:param product_info Config: The product description
:param logger Logger: The logger instance to display messages
env_script = product_info.environ.env_script
# Check that the script exists
if not os.path.exists(env_script):
- raise Exception(
- _("Environment script not found: %s") % env_script)
+ raise Exception(_("Environment script not found: %s") % env_script)
if not self.silent and logger is not None:
- logger.write(" ** load %s\n" % env_script, 4)
+ logger.info(" ** load %s\n" % env_script)
# import the script and run the set_env function
try:
pyproduct = imp.load_source(product_info.name + "_env_script",
env_script)
if not native:
- pyproduct.set_env(self,
- product_info.install_dir,
- product_info.version)
+ pyproduct.set_env(self, product_info.install_dir, product_info.version)
else:
if "set_nativ_env" in dir(pyproduct):
pyproduct.set_nativ_env(self)
except:
- __, exceptionValue, exceptionTraceback = sys.exc_info()
+ tmp , exceptionValue, exceptionTraceback = sys.exc_info()
print(exceptionValue)
import traceback
traceback.print_tb(exceptionTraceback)
return
# Check that the script exists
if not os.path.exists(script_path):
- raise Exception(
- _("Environment script not found: %s") % script_path)
+ raise Exception(_("Environment script not found: %s") % script_path)
if not self.silent and logger is not None:
- logger.write(" ** load %s\n" % script_path, 4)
+ logger.info(" ** load %s\n" % script_path)
script_basename = os.path.basename(script_path)
if script_basename.endswith(".py"):
"""Class to dump the environment to a file.
"""
def __init__(self, config, logger, out_dir, src_root, env_info=None):
- '''Initialization.
+ """Initialization
:param cfg Config: the global config
:param logger Logger: The logger instance to display messages
:param out_dir str: The directory path where t put the output files
:param src_root str: The application working directory
:param env_info str: The list of products to add in the files.
- '''
+ """
self.config = config
self.logger = logger
self.out_dir = out_dir
:rtype: str
"""
if not self.silent:
- self.logger.write(_("Create environment file %s\n") %
- UTS.label(filename), 3)
+ self.logger.info(_("Create environment file %s\n") % UTS.label(filename))
# create then env object
env_file = open(os.path.join(self.out_dir, filename), "w")
- tmp = src.fileEnviron.get_file_environ(env_file,
- shell,
- {})
+ tmp = src.fileEnviron.get_file_environ(env_file, shell, {})
env = SalomeEnviron(self.config, tmp, forBuild, for_package=for_package)
env.silent = self.silent
# The list of products to launch
lProductsName = env.get_names(self.config.APPLICATION.products.keys())
- env.set( "SALOME_MODULES", ','.join(lProductsName))
+ env.set( "SALOME_MODULES", ','.join(lProductsName))
- # set the products
- env.set_products(self.logger,
- src_root=self.src_root)
+ # set the product
+ env.set_products(self.logger, src_root=self.src_root)
# add cleanup and close
env.finish(True)
designed for a package.
"""
if not self.silent:
- self.logger.write(_("Create configuration file %s\n") %
- UTS.label(filename.name), 3)
+ self.logger.info(_("Create configuration file %s\n") % UTS.label(filename.name))
# create then env object
tmp = src.fileEnviron.get_file_environ(filename,
tmp,
forBuild=False,
for_package=for_package,
- enable_simple_env_script = with_commercial)
+ enable_simple_env_script=with_commercial)
env.silent = self.silent
if self.env_info is not None:
# The list of products to launch
lProductsName = env.get_names(self.config.APPLICATION.products.keys())
- env.set( "SALOME_MODULES", ','.join(lProductsName))
+ env.set( "SALOME_MODULES", ','.join(lProductsName))
# set the products
env.set_products(self.logger,
env.finish(True)
class Shell:
- """Definition of a Shell.
+ """\
+ Definition of a Shell.
"""
def __init__(self, name, extension):
- '''Initialization.
+ """Initialization.
:param name str: the shell name
:param extension str: the shell extension
- '''
+ """
self.name = name
self.extension = extension
import pickle
import subprocess
+
def show_progress(logger, top, delai, ss=""):
"""shortcut function to display the progression
:param delai int: the number max
:param ss str: the string to display
"""
- logger.write("\r%s\r%s %s / %s " % ((" " * 30), ss, top, (delai - top)), 4,
- False)
- logger.flush()
+ logger.info("\r%s\r%s %s / %s " % ((" " * 30), ss, top, (delai - top)))
+
-def write_back(logger, message, level):
+def write_back(logger, message):
"""shortcut function to write at the begin of the line
:param logger Logger: The logging instance
:param message str: the text to display
:param level int: the level of verbosity
"""
- logger.write("\r%s\r%s" % ((" " * 40), message), level)
+ logger.info("\r%s\r%s" % ((" " * 40), message))
+
-# Launch command
-# --------------
def launch_command(cmd, logger, cwd, args=[], log=None):
+ """Launch command"""
if log:
log = file(log, "a")
- logger.write("launch: %s\n" % cmd, 5, screenOnly=True)
+ logger.info("launch: %s\n" % cmd)
for arg in args:
cmd += " " + arg
prs = subprocess.Popen(cmd,
executable='/bin/bash')
return prs
-# Launch a batch
-# --------------
+
def batch(cmd, logger, cwd, args=[], log=None, delai=20, sommeil=1):
+ """Launch a batch"""
proc = launch_command(cmd, logger, cwd, args, log)
top = 0
sys.stdout.softspace = True
if time.time() - begin >= 1:
show_progress(logger, top, delai, "batch:")
if top == delai:
- logger.write("batch: time out KILL\n", 3)
+ logger.info("batch: time out KILL")
import signal
os.kill(proc.pid, signal.SIGTERM)
break
top += 1
sys.stdout.flush()
else:
- write_back(logger, "batch: exit (%s)\n" % str(proc.returncode), 5)
+ write_back(logger, "batch: exit (%s)\n" % str(proc.returncode))
return (proc.returncode == 0), top
-# Launch a salome process
-# -----------------------
+
def batch_salome(cmd, logger, cwd, args, getTmpDir,
pendant="SALOME_Session_Server", fin="killSalome.py",
log=None, delai=20, sommeil=1, delaiapp=0):
+ """Launch a salome process"""
beginTime = time.time()
launch_command(cmd, logger, cwd, args, log)
if found:
write_back(logger, "batch_salome: started\n", 5)
else:
- logger.write("batch_salome: FAILED to launch salome or appli\n", 3)
+ logger.warning("batch_salome: FAILED to launch salome or appli")
return False, -1
# salome launched run the script
show_progress(logger, top, delai, "running salome or appli:")
if not os.access(os.path.join(tmp_dir, pidictFile), os.F_OK):
- write_back(logger, "batch_salome: exit\n", 5)
+ write_back(logger, "batch_salome: exit")
code = True
elif top >= delai:
# timeout kill the test
os.system(fin)
- logger.write("batch_salome: time out KILL\n", 3)
+ logger.info("batch_salome: time out KILL")
code = False
else:
# still waiting
{ 'root': server, 'base': base, 'where': str(where.base()),
'tag': opttag, 'product': product, 'command': cmd }
- logger.write(command + "\n", 5)
+ logger.debug(command)
if not where.dir().exists():
where.dir().make()
logger.logTxtFile.write(command + "\n")
- logger.write(command + "\n", 5)
+ logger.debug(command)
logger.logTxtFile.write("\n" + command + "\n")
logger.logTxtFile.flush()
res = subprocess.call(command,
symlinks=True)
def prepare_testbase_from_dir(self, testbase_name, testbase_dir):
- self.logger.write(_("get test base from dir: %s\n") % \
- UTS.label(testbase_dir), 3)
+ self.logger.info(_("get test base from dir: %s\n") % UTS.label(testbase_dir))
if not os.access(testbase_dir, os.X_OK):
raise Exception(
_("testbase %(name)s (%(dir)s) does not exist ...\n") % \
testbase_name,
testbase_base,
testbase_tag):
- self.logger.write(
- _("get test base '%(testbase)s' with '%(tag)s' tag from git\n") % \
- { "testbase" : UTS.label(testbase_name),
- "tag" : UTS.label(testbase_tag) },
- 3)
+ self.logger.info( _("get test base '%s' with '%s' tag from git\n") % \
+ (UTS.label(testbase_name), UTS.label(testbase_tag)) )
try:
def set_signal(): # pragma: no cover
"""see http://bugs.python.org/issue1652"""
'base': testbase_base,
'dir': testbase_name }
- self.logger.write("> %s\n" % cmd, 5)
+ self.logger.debug("> %s" % cmd)
if src.architecture.is_windows():
# preexec_fn not supported on windows platform
res = subprocess.call(cmd,
sys.exit(0)
def prepare_testbase_from_svn(self, user, testbase_name, testbase_base):
- self.logger.write(_("get test base '%s' from svn\n") %
- UTS.label(testbase_name), 3)
+ self.logger.info(_("get test base '%s' from svn\n") % UTS.label(testbase_name))
try:
def set_signal(): # pragma: no cover
"""see http://bugs.python.org/issue1652"""
'dir': testbase_name }
# Get the application environment
- self.logger.write(_("Set the application environment\n"), 5)
+ self.logger.debug(_("Set the application environment"))
env_appli = src.environment.SalomeEnviron(self.config,
src.environment.Environ(dict(os.environ)))
env_appli.set_application_env(self.logger)
- self.logger.write("> %s\n" % cmd, 5)
+ self.logger.debug("> %s" % cmd)
if src.architecture.is_windows():
# preexec_fn not supported on windows platform
res = subprocess.call(cmd,
log=logWay,
delaiapp=time_out_salome)
- self.logger.write("status = %s, elapsed = %s\n" % (status, elapsed), 5)
+ self.logger.debug("status = %s, elapsed = %s\n" % (status, elapsed))
# create the test result to add in the config object
test_info = PYCONF.Mapping(self.config)
# Runs all tests of a session.
def run_session_tests(self):
- self.logger.write(self.write_test_margin(2), 3)
- self.logger.write("Session = %s\n" % \
- UTS.label(self.currentsession), 3, False)
+ self.logger.info(self.write_test_margin(2))
+ self.logger.info("Session = %s\n" % UTS.label(self.currentsession))
# prepare list of tests to run
tests = os.listdir(os.path.join(self.currentDir,
##
# Runs all tests of a grid.
def run_grid_tests(self):
- self.logger.write(self.write_test_margin(1), 3)
- self.logger.write("grid = %s\n" % \
- UTS.label(self.currentgrid), 3, False)
+ self.logger.info(self.write_test_margin(1))
+ self.logger.info("grid = %s\n" % UTS.label(self.currentgrid))
grid_path = os.path.join(self.currentDir, self.currentgrid)
sessions = sorted(sessions, key=str.lower)
for session_ in sessions:
if not os.path.exists(os.path.join(grid_path, session_)):
- self.logger.write(self.write_test_margin(2), 3)
- self.logger.write(
- UTS.red("Session %s not found" % session_) + "\n", 3, False)
+ self.logger.info(self.write_test_margin(2))
+ self.logger.warning("Session %s not found" % session_))
else:
self.currentsession = session_
self.run_session_tests()
os.environ['TT_BASE_RESSOURCES'] = res_dir
logger.debug(" %s = %s\n" % ("TT_BASE_RESSOURCES", res_dir)
- self.logger.write("\n", 4, False)
- self.logger.write(self.write_test_margin(0), 3)
+ self.logger.info(self.write_test_margin(0))
testbase_label = "Test base = %s\n" % UTS.label(self.currentTestBase)
- self.logger.write(testbase_label, 3, False)
- self.logger.write("-" * len(UTS.cleancolor(testbase_label)), 3)
- self.logger.write("\n", 3, False)
+ self.logger.info(testbase_label)
+ self.logger.info("-" * len(UTS.cleancolor(testbase_label)))
# load settings
settings_file = os.path.join(res_dir, "test_settings.py")
if os.path.exists(settings_file):
gdic, ldic = {}, {}
execfile(settings_file, gdic, ldic)
- self.logger.write(_("Load test settings\n"), 3)
+ self.logger.info(_("Load test settings"))
self.settings = ldic['settings_dic']
self.ignore_tests = ldic['known_failures_list']
if isinstance(self.ignore_tests, list):
self.ignore_tests = {}
- self.logger.write(UTS.red("known_failur"
- "es_list must be a dictionary (not a list)") + "\n", 1, False)
+ self.logger.error("known failures must be a dictionary (not a list)")
else:
self.ignore_tests = {}
self.settings.clear()
grids = self.grids # given by user
else:
# select all the grids (i.e. directories) in the directory
- grids = filter(lambda l: l not in C_IGNORE_GRIDS,
- os.listdir(self.currentDir))
- grids = filter(lambda l: os.path.isdir(
- os.path.join(self.currentDir, l)),
- grids)
+ grids = filter(lambda l: l not in C_IGNORE_GRIDS, os.listdir(self.currentDir))
+ grids = filter(lambda l: os.path.isdir(os.path.join(self.currentDir, l)), grids)
grids = sorted(grids, key=str.lower)
for grid in grids:
if not os.path.exists(os.path.join(self.currentDir, grid)):
- self.logger.write(self.write_test_margin(1), 3)
- self.logger.write(UTS.red(
- "grid %s does not exist\n" % grid), 3, False)
+ self.logger.info(self.write_test_margin(1))
+ self.logger.error("grid %s does not exist" % grid))
else:
self.currentgrid = grid
self.run_grid_tests()
if len(script) == 0:
return
- self.logger.write("\n", 2, False)
if not os.path.exists(script):
self.logger.warning("script not found: %s" % script)
else:
# calculate total execution time
totalTime = datetime.datetime.now() - initTime
totalTime -= datetime.timedelta(microseconds=totalTime.microseconds)
- self.logger.write("\n\n" + _("=== END TESTS %s\n") % str(totalTime))
+ self.logger.info("\n\n" + _("=== END TESTS %s\n") % str(totalTime))
# Start the tests
self.run_script('test_cleanup')
- self.logger.write("\n", 2, False)
# evaluate results
- res_count = "(%d/%d)" % \
- (self.nb_succeed, self.nb_run - self.nb_acknoledge)
-
+ res_count = "(%d/%d)" % (self.nb_succeed, self.nb_run - self.nb_acknoledge)
res_out = _("Tests Results: (%d/%d)\n") % (self.nb_succeed, self.nb_run)
+
if self.nb_succeed == self.nb_run:
-
res_out = UTS.green(res_out)
else:
res_out = UTS.red(res_out)
+
self.logger.info(res_out)
if self.nb_timeout > 0: