From 441891c830d885e91d94eefeabae1ba2eb3e8885 Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Wed, 27 Jun 2018 12:50:13 +0200 Subject: [PATCH] sat as no link --- salomeTools.py | 87 ------------------------------------------- sat | 88 +++++++++++++++++++++++++++++++++++++++++++- src/logger.py | 2 +- src/loggingSimple.py | 2 +- src/xmlManager.py | 4 +- 5 files changed, 91 insertions(+), 92 deletions(-) delete mode 100755 salomeTools.py mode change 120000 => 100755 sat diff --git a/salomeTools.py b/salomeTools.py deleted file mode 100755 index a8e1fd6..0000000 --- a/salomeTools.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python -#-*- coding:utf-8 -*- - -# 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 -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# 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 - -""" -This file is the main entry file to use salomeTools, -in mode Command Line Argument(s) (CLI) -""" - -import os -import sys - -# 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__)) -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 - -import src.logger as LOG -import src.debug as DBG # Easy print stderr (for DEBUG only) - -logger = LOG.getDefaultLogger() - -################################# -# MAIN -################################# -if __name__ == "__main__": - from src.salomeTools import Sat # it is time to do import - - _debug = False # Have to be False in production (for programmers DEBUG only) - DBG.push_debug(_debug) # as __main__ with sys.exit so no need pop_debug - - args = sys.argv[1:] # skip useless "sat' - sat = Sat(logger) # instantiate the salomeTools class - - try: - returnCode = sat.execute_cli(args) - 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_exception(msg)) - 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.step("sat exit code: %s" % returnCode) - else: - # KO warning as known problem have to say why - logger.warning("sat exit code: %s" % returnCode) - logger.close() # important to close logger - sys.exit(returnCode.toSys()) - - -else: - logger.critical("forbidden/unexpected mode for __name__ '%s'" % __name__) - logger.close() # important to close logger - sys.exit(KOSYS) - - - diff --git a/sat b/sat deleted file mode 120000 index 19cd1ab..0000000 --- a/sat +++ /dev/null @@ -1 +0,0 @@ -salomeTools.py \ No newline at end of file diff --git a/sat b/sat new file mode 100755 index 0000000..a8e1fd6 --- /dev/null +++ b/sat @@ -0,0 +1,87 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +# 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# 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 + +""" +This file is the main entry file to use salomeTools, +in mode Command Line Argument(s) (CLI) +""" + +import os +import sys + +# 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__)) +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 + +import src.logger as LOG +import src.debug as DBG # Easy print stderr (for DEBUG only) + +logger = LOG.getDefaultLogger() + +################################# +# MAIN +################################# +if __name__ == "__main__": + from src.salomeTools import Sat # it is time to do import + + _debug = False # Have to be False in production (for programmers DEBUG only) + DBG.push_debug(_debug) # as __main__ with sys.exit so no need pop_debug + + args = sys.argv[1:] # skip useless "sat' + sat = Sat(logger) # instantiate the salomeTools class + + try: + returnCode = sat.execute_cli(args) + 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_exception(msg)) + 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.step("sat exit code: %s" % returnCode) + else: + # KO warning as known problem have to say why + logger.warning("sat exit code: %s" % returnCode) + logger.close() # important to close logger + sys.exit(returnCode.toSys()) + + +else: + logger.critical("forbidden/unexpected mode for __name__ '%s'" % __name__) + logger.close() # important to close logger + sys.exit(KOSYS) + + + diff --git a/src/logger.py b/src/logger.py index f50ae77..4400540 100755 --- a/src/logger.py +++ b/src/logger.py @@ -468,7 +468,7 @@ def setCurrentLogger(logger): """temporary send all in stdout as simple logging logger""" if len(_currentLogger) == 0: _currentLogger.append(logger) - logger.warning("set current logger as %s" % logger.name) + logger.debug("set current logger as %s" % logger.name) else: if _currentLogger[0].name != logger.name: # logger.debug("quit current logger as default %s" % _currentLogger[0].name) diff --git a/src/loggingSimple.py b/src/loggingSimple.py index 7073e4d..07bae88 100755 --- a/src/loggingSimple.py +++ b/src/loggingSimple.py @@ -410,7 +410,7 @@ def initLoggerAsDefault(logger, fmt=None, level=None): if level is not None: # level could be modified during execution handler.setLevel(level) # on screen log as user wants else: - handler.setLevel(LOGI.STEP) # on screen no log step, which are in xml files + handler.setLevel(LOGI.INFO) # on screen no log step, which are in xml files return diff --git a/src/xmlManager.py b/src/xmlManager.py index d619980..20ef4e5 100644 --- a/src/xmlManager.py +++ b/src/xmlManager.py @@ -77,7 +77,7 @@ class XmlLogFile(object): return res -def write_tree(self, stylesheet=None, file_path = None): + def write_tree(self, stylesheet=None, file_path = None): '''Write the xml tree in the log file path. Add the stylesheet if asked. :param stylesheet str: The stylesheet to apply to the xml file @@ -241,4 +241,4 @@ def write_report(filename, xmlroot, stylesheet): f.write("\n" % stylesheet) f.write(etree.tostring(xmlroot, encoding='utf-8')) f.close() - \ No newline at end of file + -- 2.39.2