From e56b33281d7fc8abbb03ebf17702f7c49380768e Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Mon, 25 Jun 2018 16:46:34 +0200 Subject: [PATCH] add AllTestLauncher and src/loggingSimple.py etc... --- AllTestLauncherSat.py | 364 +++++++++ __init__.py | 1 + commands/__init__.py | 41 + commands/config.py | 4 +- commands/doc.py | 11 +- commands/init.py | 2 +- commands/job.py | 11 +- commands/jobs.py | 8 +- commands/log.py | 8 +- commands/run.py | 11 +- commands/shell.py | 7 +- data/local.pyconf | 7 +- data/local_original.pyconf | 16 + data/local_wambeke_cea.pyconf | 21 + data/local_wambeke_home.pyconf | 18 + salomeTools.py | 562 ++------------ src/debug.py | 194 +++-- src/logger.py | 87 ++- src/loggingSimple.py | 509 ++++++++++++ src/options.py | 17 +- src/returnCode.py | 234 ++++++ src/salomeTools.py | 731 ++++++++++++++++++ src/utilsSat.py | 77 ++ test/APPLI_TEST/APPLI_TEST.pyconf | 45 ++ test/README_config_0_3_9.txt | 2 + test/__init__.py | 0 test/_testTools/tools.py | 77 -- test/initializeTest.py | 61 ++ test/test_020_debug.py | 130 ++++ test/test_024_logging.py | 160 ++++ test/test_035_pyconf.py | 266 +++++++ test/test_100_satHelp.py | 143 ++++ test/test_500_APPLI_TEST.py | 129 ++++ test/test_501_paramiko.py | 205 +++++ test/test_sat5_0/README | 1 + test/test_sat5_0/__init__.py | 0 .../compilation/test_compilation.py | 69 +- .../compilation/test_configure.py | 48 +- .../compilation/test_make.py | 51 +- .../compilation/test_makeinstall.py | 34 +- .../config/test_create_user_pyconf.py} | 65 +- .../config/test_option_copy.py} | 29 +- .../config/test_option_edit.py} | 39 +- .../config/test_option_value.py} | 47 +- .../config/test_option_value_2.py} | 47 +- .../{ => test_sat5_0}/environ/test_environ.py | 53 +- test/{ => test_sat5_0}/job/test_job.py | 59 +- test/{ => test_sat5_0}/jobs/test_jobs.py | 66 +- .../log/test_launch_browser.py} | 128 +-- .../log/test_launch_browser2.py} | 30 +- test/{ => test_sat5_0}/prepare/test_clean.py | 76 +- test/{ => test_sat5_0}/prepare/test_patch.py | 62 +- .../{ => test_sat5_0}/prepare/test_prepare.py | 52 +- test/{ => test_sat5_0}/prepare/test_source.py | 82 +- test/{ => test_sat5_0}/run_all.sh | 4 +- test/{ => test_sat5_0}/shell/test_shell.py | 42 +- test/{ => test_sat5_0}/test/test_command.py | 40 +- .../HTMLTestRunner.py | 0 unittestpy/__init__.py | 0 59 files changed, 3860 insertions(+), 1423 deletions(-) create mode 100755 AllTestLauncherSat.py create mode 100644 __init__.py create mode 100644 commands/__init__.py create mode 100644 data/local_original.pyconf create mode 100644 data/local_wambeke_cea.pyconf create mode 100644 data/local_wambeke_home.pyconf mode change 100644 => 100755 src/debug.py mode change 100644 => 100755 src/logger.py create mode 100755 src/loggingSimple.py mode change 100644 => 100755 src/options.py create mode 100644 src/returnCode.py create mode 100755 src/salomeTools.py create mode 100644 src/utilsSat.py create mode 100644 test/APPLI_TEST/APPLI_TEST.pyconf create mode 100644 test/README_config_0_3_9.txt create mode 100755 test/__init__.py delete mode 100644 test/_testTools/tools.py create mode 100755 test/initializeTest.py create mode 100755 test/test_020_debug.py create mode 100755 test/test_024_logging.py create mode 100755 test/test_035_pyconf.py create mode 100755 test/test_100_satHelp.py create mode 100755 test/test_500_APPLI_TEST.py create mode 100755 test/test_501_paramiko.py create mode 100644 test/test_sat5_0/README create mode 100644 test/test_sat5_0/__init__.py rename test/{ => test_sat5_0}/compilation/test_compilation.py (84%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/compilation/test_configure.py (76%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/compilation/test_make.py (75%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/compilation/test_makeinstall.py (71%) mode change 100644 => 100755 rename test/{config/create_user_pyconf.py => test_sat5_0/config/test_create_user_pyconf.py} (71%) mode change 100644 => 100755 rename test/{config/option_copy.py => test_sat5_0/config/test_option_copy.py} (73%) mode change 100644 => 100755 rename test/{config/option_edit.py => test_sat5_0/config/test_option_edit.py} (69%) mode change 100644 => 100755 rename test/{config/option_value.py => test_sat5_0/config/test_option_value.py} (74%) mode change 100644 => 100755 rename test/{config/option_value_2.py => test_sat5_0/config/test_option_value_2.py} (70%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/environ/test_environ.py (76%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/job/test_job.py (69%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/jobs/test_jobs.py (72%) mode change 100644 => 100755 rename test/{log/launch_browser.py => test_sat5_0/log/test_launch_browser.py} (74%) mode change 100644 => 100755 rename test/{log/launch_browser2.py => test_sat5_0/log/test_launch_browser2.py} (66%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/prepare/test_clean.py (76%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/prepare/test_patch.py (77%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/prepare/test_prepare.py (72%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/prepare/test_source.py (74%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/run_all.sh (97%) rename test/{ => test_sat5_0}/shell/test_shell.py (71%) mode change 100644 => 100755 rename test/{ => test_sat5_0}/test/test_command.py (75%) mode change 100644 => 100755 rename {test/_testTools => unittestpy}/HTMLTestRunner.py (100%) create mode 100644 unittestpy/__init__.py diff --git a/AllTestLauncherSat.py b/AllTestLauncherSat.py new file mode 100755 index 0000000..8b74f2f --- /dev/null +++ b/AllTestLauncherSat.py @@ -0,0 +1,364 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2008-2018 CEA/DEN +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.com + + +""" +Test all SAT unittest files (test*.py) existing in subdirectories of a root directory + +| Example: +| >> AllTestLauncherSat.py --rootPath='.' --pattern='test_???_*.py' +""" + +""" +#### base of algorithm functionality + +#see http://www.voidspace.org.uk/python/articles/introduction-to-unittest.shtml + +import unittest + +import test_something +import test_something2 +import test_something3 + +loader = unittest.TestLoader() + +suite = loader.loadTestsFromModule(test_something) +suite.addTests(loader.loadTestsFromModule(test_something2)) +suite.addTests(loader.loadTestsFromModule(test_something3)) + +runner = unittest.TextTestRunner(verbosity=2) +result = runner.run(suite) +""" + + +import os +import sys +import unittest +import traceback +import argparse as AP + +import glob +import fnmatch +import pprint as PP #pretty print + +debug = False +verboseImport = True + + +# get path to origin sources +defaultdir = os.path.dirname(os.path.realpath(__file__)) +# get path to salomeTools sources +satdir = defaultdir +srcdir = os.path.join(satdir, 'src') +cmdsdir = os.path.join(satdir, 'commands') + +# Make the src & commands package accessible from all code +sys.path.insert(0, satdir) +sys.path.insert(0, srcdir) # TODO remove that +sys.path.insert(0, cmdsdir) # TODO remove that + +_user = os.environ['USER'] +# wambeke is christian at home +_developpers = ["christian", "wambeke",] # ...who wants + +def errPrint(aStr): + """stderr to avoid write in html or xml file log message""" + sys.stderr.write(aStr + '\n') + +try: + import unittestpy.HTMLTestRunner as HTST +except: + HTST = None + errPrint(""" +WARNING: no HTML output available. + try find 'test/unittestpy/HTMLTestRunner.py'. +""") + + +try: + import xmlrunner as XTST +except: + XTST = None + errPrint(""" +WARNING: no XML output available for unittest. + try 'pip install unittest-xml-reporting'. +""") + + +################################################################### +def locate(pattern, root=os.curdir): + """ + Locate all files matching supplied filename pattern in and below + supplied root directory. + """ + result = [] + for path, dirs, files in os.walk(os.path.abspath(root)): + for filename in fnmatch.filter(files, pattern): + result.append( os.path.join(path, filename) ) + return result + +def printEnv(search=""): + """ + list all environment variables which name contains search string + example: + import AllTestLauncher as ATL + ATL.printEnv("ROOT_") + """ + env=os.environ + for i in sorted(env): + if search in i: + print(i) + +def grepInEnv(search=""): + """ + list all environment variables which contains search string + example: + import AllTestLauncher as ATL + ATL.grepInEnv("XDATA") + """ + env=os.environ + for i in sorted(env): + done=False + for j in env[i].split(":"): + if search in j: + if not done: + print(i+" contains ") + done=True + print(" "+j) + +def format_exception(msg, limit=None, trace=None): + """ + Format a stack trace and the exception information. + as traceback.format_exception(), + with all traceback only if user in ._developpers + """ + etype, value, tb = sys.exc_info() + if _user in _developpers: + res = "\n" + msg + if tb: + res += "\nTraceback (most recent call last):\n" + res += "".join(traceback.format_tb(tb, limit)) #[:-1]) + res += "\n<" + res += "\n".join(traceback.format_exception_only(etype, value)) + return res + else: + res = "\n" + msg + if tb: + res += "\nTraceback:\n" + res += "".join(traceback.format_tb(tb, limit)[-1:]) #[:-1]) + res += "\n<" + res += "".join(traceback.format_exception_only(etype, value)) + return res + +################################################################### +def runOnArgs(args): + """ + launch tests on args.pattern files + """ + fromFileOrPath = args.rootPath + fileTestPattern = args.pattern + if fromFileOrPath == None: + directory, name = os.path.split( os.path.realpath( __file__ ) ) + else: + if os.path.isdir(fromFileOrPath): + directory, name = (fromFileOrPath, None) + fileTestPatternCurrent = fileTestPattern + elif os.path.isfile(fromFileOrPath): + directory, name = os.path.split( os.path.realpath( fromFileOrPath ) ) + fileTestPatternCurrent = name + else: + mess = "Cannot get file or directory '%s'" % fromFileOrPath + errPrint("ERROR: " + mess) + return None + #raise Exception("Cannot get file or directory '%s'" % fromFileOrPath) + + #files = glob.glob(os.path.join(directory, "*Test.py")) + files = sorted(locate(fileTestPatternCurrent, directory)) + + filesForTest={} + + for aFile in files: + aDir, aName = os.path.split(aFile) + aImport, ext = os.path.splitext(aName) + + try: + if aFile in list(filesForTest.keys()): + print("WARNING: imported yet: "+aFile) + else: + sys.path.insert(0, aDir) + done = True + if verboseImport: errPrint("try import '%s'" % aImport) + aModule = __import__(aImport, globals(), locals(), []) + del sys.path[0] + done = False + filesForTest[aFile] = (aImport, aModule) + except Exception as e: + if done: + del sys.path[0] #attention of sys.path appends + done = False + msg = "ERROR: AllTestLauncher: import '%s':" % aFile + err = format_exception(msg) + errPrint(err) + continue + + listfilesForTest = sorted(filesForTest.keys()) + result = None + + errPrint("AllTestLauncher test files:\n %s" % PP.pformat(listfilesForTest)) + + if len(listfilesForTest) == 0: + if debug: errPrint("WARNING: AllTestLauncher: empty list of test files") + return None + + loader = unittest.TestLoader() + suite = None + + for i,k in enumerate(listfilesForTest): + if debug: errPrint("Test: %s %s" % (i, k)) + if i == 0: + suite = loader.loadTestsFromModule( filesForTest[k][1] ) + pass + else: + suite.addTests( loader.loadTestsFromModule( filesForTest[k][1] ) ) + pass + + if args.type == "std": + runner = unittest.TextTestRunner(verbosity=args.verbosity) + elif args.type == "html": + runner = HTST.HTMLTestRunner(verbosity=args.verbosity, ) + elif args.type == "xml": + if args.name == 'stdout': + #all-in-one xml output at 'sys.stdout' for pipe redirection + runner = XTST.XMLTestRunner(verbosity=args.verbosity, output=sys.stdout) + else: + #one file xml per test in suite in args.name directory + runner = XTST.XMLTestRunner(verbosity=args.verbosity, output=args.name) + else: + errPrint("ERROR: unknown type of output: '%s'" % args.type) + return None + + if suite != None: result = runner.run(suite) + return result + +################################################################### +def runFromEnvVar(envVar, fileTestPattern="*Test.py"): + """ + example: + import AllTestLauncher as ATL + ATL.runFromEnvVar("MICROGEN_ROOT_DIR") + ATL.runFromEnvVar("MICROGEN_ROOT_DIR", "aggregate_*GJKTest.py") + """ + env=os.environ + res = [] + for i in sorted(env): + if envVar in i: + res.append(i) + if len(res) > 1: + mess = "multiple environment variable for '%s': %s" % (envVar, str(res)) + errPrint("ERROR: " + mess) + return None + if len(res) < 1: + mess = "no environment variable for '%s'" % (envVar) + errPrint("ERROR: " + mess) + return None + res = res[0] + tmp = env[res].split(":") + if len(tmp) > 1: + mess = "need only one path in environment variable '%s'" % (res) + errPrint("ERROR: " + mess) + return None + run(fromFileOrPath=env[res], fileTestPattern=fileTestPattern) + + +################################################################### +def getParser(): + parser = AP.ArgumentParser(description='launch All salomeTools python tests', argument_default=None) + + parser.add_argument( + '-d', '--debug', + help='set debug mode, more verbose', + action='store_true', + ) + parser.add_argument( + '-v', '--verbosity', + help='set verbosity of unittests [0|1|2...]', + default=2, + metavar='int' + ) + parser.add_argument( + '-r', '--rootPath', + help="""\ +dir name with absolute or relative path stand for root directory +of recursive searching unittest python files +""", + default=defaultdir, + metavar='dirPath' + ) + parser.add_argument( + '-p', '--pattern', + help="file pattern for unittest files ['test_*.py'|'*Test.py'...]", + default="test_???_*.py", # as alphabetical ordered test site + metavar='filePattern' + ) + parser.add_argument( + '-t', '--type', + help="type of output: ['std'(standart ascii)|'xml'|'html']", + default="std", + choices=['std', 'xml', 'html'], + metavar='outputType' + ) + parser.add_argument( + '-n', '--name', + help="""\ +(only for type xml) +name of directory output: ['test_reports'|...]. +If name = 'stdout' then all-in-one xml output at 'sys.stdout'. For pipe redirection: +'>> AllTestLauncher.py -t xml -n stdout > tmp.xml' +""", + default="test_reports", + metavar='dirName' + ) + return parser + +#export PATH=defaultdir:${PATH} + +################################################################### +if __name__ == '__main__': + # Make the src & command package accessible from all code + # as export PYTHONPATH=defaultdir:${PYTHONPATH} + # https://docs.python.org/2/library/os.html + # On some platforms, including FreeBSD and Mac OS X, + # setting environ may cause memory leak + # so use sys.path + # errPrint("INFO : AllTestLauncher sys.path:\n'%s'" % PP.pformat(sys.path) + if defaultdir not in sys.path[0]: + sys.path.insert(0, defaultdir) + errPrint("WARNING : sys.path prepend '%s'\n" % defaultdir) + + args = getParser().parse_args(sys.argv[1:]) + debug = args.debug + directory = os.path.realpath(args.rootPath) + if debug: print("INFO: args:\n %s" % PP.pformat(args)) + sys.path.insert(0, directory) #supposed to be root of a package + + runOnArgs(args) + + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..2646961 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +__all__ = ['src', 'commands', "test", "unittestpy", ] \ No newline at end of file diff --git a/commands/__init__.py b/commands/__init__.py new file mode 100644 index 0000000..c3aa9d1 --- /dev/null +++ b/commands/__init__.py @@ -0,0 +1,41 @@ + +""" +import os +import gettext + +# get path to salomeTools sources +satdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +srcdir = os.path.join(satdir, 'src') +cmdsdir = os.path.join(satdir, 'commands') + +# load resources for internationalization +gettext.install("salomeTools", os.path.join(srcdir, "i18n")) + +import application +import check +import clean +import compile +import config +import configure +import doc +import environ +import find_duplicates +import generate +import init +import job +import jobs +import launcher +import log +import make +import makeinstall +import package +import patch +import prepare +import profile +import run +import script +import shell +import source +import template +import test +""" diff --git a/commands/config.py b/commands/config.py index 547fd9e..42fb8d9 100644 --- a/commands/config.py +++ b/commands/config.py @@ -882,7 +882,7 @@ def run(args, runner, logger): 'open_application' not in runner.cfg): # edit user pyconf usercfg = os.path.join(runner.cfg.VARS.personalDir, 'SAT.pyconf') - logger.write(_("Openning %s\n" % usercfg), 3) + logger.write(_("Opening %s\n" % usercfg), 3) src.system.show_in_editor(editor, usercfg, logger) else: # search for file .pyconf and open it @@ -890,7 +890,7 @@ def run(args, runner, logger): pyconf_path = os.path.join(path, runner.cfg.VARS.application + ".pyconf") if os.path.exists(pyconf_path): - logger.write(_("Openning %s\n" % pyconf_path), 3) + logger.write(_("Opening %s\n" % pyconf_path), 3) src.system.show_in_editor(editor, pyconf_path, logger) break diff --git a/commands/doc.py b/commands/doc.py index 0fc1fb3..42359e2 100644 --- a/commands/doc.py +++ b/commands/doc.py @@ -33,12 +33,13 @@ def description(): :rtype: str """ return _("""\ - Gives access to the sat documentation. +The doc command gives access to the sat documentation. - example: - >> sat doc # --html as default - >> sat doc --html - >> sat doc --pdf""") +example: +>> sat doc # --html as default +>> sat doc --html +>> sat doc --pdf +""") def run(args, runner, logger): '''method that is called when salomeTools is called with log parameter. diff --git a/commands/init.py b/commands/init.py index 0332557..5a35eb4 100644 --- a/commands/init.py +++ b/commands/init.py @@ -120,7 +120,7 @@ def description(): :return: The text to display for the init command description. :rtype: str ''' - return _("Changes the local settings of SAT.") + return _("The init command Changes the local settings of SAT.") def run(args, runner, logger): '''method that is called when salomeTools is called with init parameter. diff --git a/commands/job.py b/commands/job.py index cca442d..ec23cd8 100644 --- a/commands/job.py +++ b/commands/job.py @@ -19,7 +19,7 @@ import os import src -import salomeTools +import src.salomeTools # Define all possible option for the make command : sat make parser = src.options.Options() @@ -35,9 +35,12 @@ def description(): :return: The text to display for the job command description. :rtype: str ''' - return _("Executes the commands of the job defined" - " in the jobs configuration file\n\nexample:\nsat job " - "--jobs_config my_jobs --name my_job") + return _("""\ +The job command executes the commands of the job defined in the jobs configuration file + +example: +>> sat job --jobs_config my_jobs --name my_job +""") def run(args, runner, logger): '''method that is called when salomeTools is called with job parameter. diff --git a/commands/jobs.py b/commands/jobs.py index 3d6540e..6c9b230 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -26,7 +26,13 @@ import csv import shutil import itertools import re -import paramiko + +# generate problem +try: + import paramiko +except: + paramiko = "import paramiko impossible" + pass import src import src.ElementTree as etree diff --git a/commands/log.py b/commands/log.py index 01164bf..d8def14 100644 --- a/commands/log.py +++ b/commands/log.py @@ -193,8 +193,12 @@ def description(): :return: The text to display for the log command description. :rtype: str ''' - return _("Gives access to the logs produced by the salomeTools commands.\n" - "\nexample:\nsat log") + return _("""\ +The log command gives access to the logs produced by the salomeTools commands. + +example: +>> sat log +""") def run(args, runner, logger): '''method that is called when salomeTools is called with log parameter. diff --git a/commands/run.py b/commands/run.py index fa08cb9..c6138e5 100644 --- a/commands/run.py +++ b/commands/run.py @@ -21,6 +21,9 @@ import subprocess import src +# Define all possible option for log command : sat run +parser = src.options.Options() +# no option more than -h as generic default def description(): '''method that is called when salomeTools is called with --help option. @@ -28,8 +31,12 @@ def description(): :return: The text to display for the run command description. :rtype: str ''' - return _("This command runs the application launcher" - " with the given arguments.\n\nexample:\nsat run SALOME-master") + return _("""\ +The run command runs the application launcher with the given arguments. + +example: +>> sat run SALOME-master +""") def run(args, runner, logger): '''method that is called when salomeTools is called with run parameter. diff --git a/commands/shell.py b/commands/shell.py index e01d32b..c213975 100644 --- a/commands/shell.py +++ b/commands/shell.py @@ -31,8 +31,11 @@ def description(): :return: The text to display for the shell command description. :rtype: str ''' - return _("Executes the shell command passed as argument.\n\nexample:" - "\nsat shell --command \"ls \\-l /tmp\"") + return _("""\ +The shell command executes the shell commands passed as argument. + +example: +>> sat shell --command "ls -l /tmp" """) def run(args, runner, logger): '''method that is called when salomeTools is called with shell parameter. diff --git a/data/local.pyconf b/data/local.pyconf index 7755af0..7ddf975 100644 --- a/data/local.pyconf +++ b/data/local.pyconf @@ -2,7 +2,7 @@ LOCAL : { base : 'default' - workdir : 'default' + workdir : '/volatile/wambeke/fromjobs' #'default' log_dir : 'default' archive_dir : 'default' VCS : None @@ -12,5 +12,10 @@ { project_file_paths : [ + "/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" ] } diff --git a/data/local_original.pyconf b/data/local_original.pyconf new file mode 100644 index 0000000..7755af0 --- /dev/null +++ b/data/local_original.pyconf @@ -0,0 +1,16 @@ + + LOCAL : + { + base : 'default' + workdir : 'default' + log_dir : 'default' + archive_dir : 'default' + VCS : None + tag : None + } + PROJECTS : + { + project_file_paths : + [ + ] + } diff --git a/data/local_wambeke_cea.pyconf b/data/local_wambeke_cea.pyconf new file mode 100644 index 0000000..e62c609 --- /dev/null +++ b/data/local_wambeke_cea.pyconf @@ -0,0 +1,21 @@ + + LOCAL : + { + base : 'default' + workdir : 'default' + log_dir : 'default' + archive_dir : 'default' + VCS : None + tag : None + } + PROJECTS : + { + project_file_paths : + [ + "/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" + ] + } diff --git a/data/local_wambeke_home.pyconf b/data/local_wambeke_home.pyconf new file mode 100644 index 0000000..c91da53 --- /dev/null +++ b/data/local_wambeke_home.pyconf @@ -0,0 +1,18 @@ + + LOCAL : + { + base : 'default' + workdir : 'default' + log_dir : 'default' + archive_dir : 'default' + VCS : None + tag : None + } + PROJECTS : + { + project_file_paths : + [ + "/home/christian/SAT_SALOME/salome.pyconf" + "/home/christian/SAT_MATIX/matix.pyconf" + ] + } diff --git a/salomeTools.py b/salomeTools.py index 84429e4..a8e1fd6 100755 --- a/salomeTools.py +++ b/salomeTools.py @@ -1,6 +1,7 @@ #!/usr/bin/env python #-*- coding:utf-8 -*- -# Copyright (C) 2010-2012 CEA/DEN + +# Copyright (C) 2010-2018 CEA/DEN # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -15,533 +16,72 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -'''This file is the main entry file to salomeTools -''' -# python imports +""" +This file is the main entry file to use salomeTools, +in mode Command Line Argument(s) (CLI) +""" + import os import sys -import re -import tempfile -import imp -import types -import gettext -import traceback -# salomeTools imports -import src +# exit OKSYS and KOSYS seems equal on linux or windows +OKSYS = 0 # OK +KOSYS = 1 # KO # get path to salomeTools sources -satdir = os.path.dirname(os.path.realpath(__file__)) +satdir = os.path.dirname(os.path.realpath(__file__)) +srcdir = os.path.join(satdir, 'src') cmdsdir = os.path.join(satdir, 'commands') -# Make the src package accessible from all code -sys.path.append(satdir) -sys.path.append(cmdsdir) - -import config - -# load resources for internationalization -#es = gettext.translation('salomeTools', os.path.join(satdir, 'src', 'i18n')) -#es.install() -gettext.install('salomeTools', os.path.join(satdir, 'src', 'i18n')) - -# The possible hooks : -# pre is for hooks to be executed before commands -# post is for hooks to be executed after commands -C_PRE_HOOK = "pre" -C_POST_HOOK = "post" - -def find_command_list(dirPath): - ''' Parse files in dirPath that end with .py : it gives commands list - - :param dirPath str: The directory path where to search the commands - :return: cmd_list : the list containing the commands name - :rtype: list - ''' - cmd_list = [] - for item in os.listdir(dirPath): - if item.endswith('.py'): - cmd_list.append(item[:-len('.py')]) - return cmd_list - -# The list of valid salomeTools commands -#lCommand = ['config', 'compile', 'prepare'] -lCommand = find_command_list(cmdsdir) - -# Define all possible option for salomeTools command : sat