try:
import unittestpy.HTMLTestRunner as HTST
-except:
+except Exception:
HTST = None
errPrint("""
WARNING: no HTML output available.
try:
import xmlrunner as XTST
-except:
+except Exception:
XTST = None
errPrint("""
WARNING: no XML output available for unittest.
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import stat
import sys
import shutil
import subprocess
import getpass
+from gettext import gettext as _
from src import ElementTree as etree
import src
if text is not None:
try:
n.text = text.strip("\n\t").decode("UTF-8")
- except:
+ except Exception:
sys.stderr.write("################ %s %s\n" % (node_name, text))
n.text = "?"
parent.append(n)
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-
import src
+from gettext import gettext as _
# Define all possible option for the check command : sat check <options>
parser = src.options.Options()
# 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 re
import os
-
import src
+from gettext import gettext as _
# Compatibility python 2/3 for input function
# input stays input for python 3 and input = raw_input for python 2
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import re
import subprocess
import src
import src.debug as DBG
+from gettext import gettext as _
# Compatibility python 2/3 for input function
# input stays input for python 3 and input = raw_input for python 2
batch=True,
verbose=0,
logger_add_link = logger)
- except:
+ except Exception:
pass
if check_salome_configuration:
env=build_environ.environ.environ,
stderr=subprocess.STDOUT).strip()
pip_build_options=int(res_pip_version.split('.')[0]) < 21
- except:
+ except Exception:
pip_build_options= True
# d- install (in python or in separate product directory)
if src.appli_test_property(config,"pip_install_dir", "python"):
import shutil
import gettext
import pprint as PP
+from gettext import gettext as _
import src
import src.logger as LOG
-import src.debug as DBG
+import src.debug as debug
import src.callerName as CALN
logger = LOG.getDefaultLogger()
if dir(a).__contains__('keys'):
vals = map(lambda x: head + '.' + x,
[m for m in a.keys() if m.startswith(tail)])
- except:
+ except Exception:
pass
for v in sorted(vals):
if options.debug:
if options.debug == ".":
# if argument is ".", print all the config
- res = DBG.indent(DBG.getStrConfigDbg(runner.cfg))
+ res = debug.indent(debug.getStrConfigDbg(runner.cfg))
logger.write("\nConfig of application %s:\n\n%s\n" % (runner.cfg.VARS.application, res))
else:
if options.debug[0] == ".": # accept ".PRODUCT.etc" as "PRODUCT.etc"
exec(aCode, globals(), aDict)
# DBG.write("globals()", globals(), True)
# DBG.write("aDict", aDict, True)
- res = DBG.indent(DBG.getStrConfigDbg(aDict["a"]))
+ res = debug.indent(debug.getStrConfigDbg(aDict["a"]))
logger.write("\nConfig.%s of application %s:\n\n%s\n" % (od, runner.cfg.VARS.application, res))
except Exception as e:
msg = "\nConfig.%s of application %s: Unknown pyconf key\n" % (od, runner.cfg.VARS.application)
# DBG.write("products", sorted(runner.cfg.APPLICATION.products.keys()), True)
src.check_config_has_application(runner.cfg)
taggedProducts = src.getProductNames(runner.cfg, options.info, logger)
- DBG.write("tagged products", sorted(taggedProducts))
+ debug.write("tagged products", sorted(taggedProducts))
for prod in sorted(taggedProducts):
if prod in runner.cfg.APPLICATION.products:
try:
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-
import src
+from gettext import gettext as _
# Define all possible option for configure command : sat configure <options>
parser = src.options.Options()
import os
import src
+from gettext import gettext as _
# Define all possible option for log command : sat doc <options>
parser = src.options.Options()
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
import shutil
import imp
import subprocess
+from gettext import gettext as _
import src
from src.versionMinorMajorPatch import MinorMajorPatch as MMP
-import src.debug as DBG
+import src.debug as debug
parser = src.options.Options()
parser.add_option('p', 'products', 'list2', 'products',
# get files to build a template GUI
try: # try new yacsgen api
gui_files = salome_compo.getGUIfilesTemplate(compo)
- except: # use old yacsgen api
+ except Exception: # use old yacsgen api
gui_files = salome_compo.getGUIfilesTemplate()
else:
gui_files = None
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
import os
import shutil
-import re
-import subprocess
+from gettext import gettext as _
import src
-import prepare
-import src.debug as DBG
+import src.debug as debug
PACKAGE_EXT=".tar.gz" # the extension we use for the packages
def run(args, runner, logger):
'''method that is called when salomeTools is called with install parameter.
'''
- DBG.write("install.run()", args)
+ debug.write("install.run()", args)
# Parse the options
(options, args) = parser.parse_args(args)
from compile import get_dependencies_graph,depth_search_graph
all_products_graph=get_dependencies_graph(all_products_infos)
#logger.write("Dependency graph of all application products : %s\n" % all_products_graph, 6)
- DBG.write("Dependency graph of all application products : ", all_products_graph)
+ debug.write("Dependency graph of all application products : ", all_products_graph)
products_infos=[]
if options.products is None:
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
import src.salomeTools
import shutil
import itertools
import re
+from gettext import gettext as _
# generate problem
try:
import paramiko
-except:
+except Exception:
paramiko = "import paramiko impossible"
pass
except paramiko.SSHException:
message = ( _("SSHException error connecting or "
"establishing an SSH session"))
- except:
+ except Exception:
message = ( _("Error connecting or establishing an SSH session"))
else:
self._connection_successful = True
": the server failed to execute the command\n")
logger.write( src.printcolors.printcError(message))
return (None, None, None)
- except:
+ except Exception:
logger.write( src.printcolors.printcError(src.KO_STATUS + '\n'))
return (None, None, None)
else:
'''
try:
pids = self.get_pids()
- except:
+ except Exception:
return ("Unable to get the pid of the command.", "")
cmd_kill = " ; ".join([("kill -2 " + pid) for pid in pids])
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import platform
import shutil
import getpass
import subprocess
import stat
+from gettext import gettext as _
import src
-import src.debug as DBG
parser = src.options.Options()
import glob
import datetime
import stat
+from gettext import gettext as _
# Compatibility python 2/3 for input function
# input stays input for python 3 and input = raw_input for python 2
x = int(rep)
if x > nb:
x = -1
- except:
+ except Exception:
x = -1
return x
src.ensure_path_exists(os.path.join(logDir, "TEST"))
shutil.copy(xsltest, os.path.join(logDir, "TEST"))
shutil.copy(imgLogo, logDir)
- except:
+ except Exception:
# we are here if an user make sat log in jenkins LOGS without write rights
# Make a warning and do nothing
logger.warning("problem for writing in directory '%s', may be not owner." % logDir)
notShownCommands = notShownCommands)
logger.write(src.printcolors.printc("OK"), 3)
- except:
+ except Exception:
logger.write(src.printcolors.printc("KO"), 3)
logger.write(" problem update hat.xml", 3)
import os
import re
+from gettext import gettext as _
import src
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
import codecs
import string
import glob
-import pprint as PP
import sys
+from gettext import gettext as _
+
+import pprint as PP
import src
-from application import get_SALOME_modules
from src.versionMinorMajorPatch import MinorMajorPatch as MMP
-import src.debug as DBG
+import src.debug as debug
+from commands.application import get_SALOME_modules
old_python = sys.version_info[0] == 2 and sys.version_info[1] <= 6
success = 0
# loop over each directory or file stored in the d_content dictionary
names = sorted(d_content.keys())
- DBG.write("add tar names", names)
+ debug.write("add tar names", names)
# used to avoid duplications (for pip install in python, or single_install_dir cases)
already_added=set()
import imp
distene = imp.load_source('distene_licence', distene_licence_file)
distene.set_distene_variables(context)
- except:
+ except Exception:
pass\n""" % licence_file
text.insert(num_line + 1, text_to_insert)
for line in text:
if not src.architecture.is_windows():
try:
t = os.getcwd()
- except:
+ except Exception:
# In the jobs, os.getcwd() can fail
t = config.LOCAL.workdir
os.chdir(tmp_working_dir)
sections = [p_info.section]
for section in sections:
if section in product_pyconf_cfg and "get_source" in product_pyconf_cfg[section]:
- DBG.write("sat package set archive mode to archive for product %s and section %s" %\
+ debug.write("sat package set archive mode to archive for product %s and section %s" %\
(p_name,section))
product_pyconf_cfg[section].get_source = "archive"
if not "archive_info" in product_pyconf_cfg[section]:
try:
project_pyconf_cfg = config.PROJECTS.projects.__getattr__(name_project)
- except:
+ except Exception:
logger.write("""
WARNING: inexisting config.PROJECTS.projects.%s, try to read now from:\n%s\n""" % (name_project, project_file_path))
project_pyconf_cfg = src.pyconf.Config(project_file_path)
options, logger))
if options.project:
- DBG.write("config for package %s" % options.project, runner.cfg)
+ debug.write("config for package %s" % options.project, runner.cfg)
d_files_to_add.update(project_package(runner.cfg, options.project, options.project_file_path, options.ftp, tmp_working_dir, options.sat, logger))
if not(d_files_to_add):
# case if no application, only package sat as 'sat package -t'
try:
app = runner.cfg.APPLICATION
- except:
+ except Exception:
app = None
# unconditionaly remove the tmp_local_working_dir
shutil.rmtree(tmp_local_working_dir)
# remove the tmp directory, unless user has registered as developer
- if os.path.isdir(tmp_working_dir) and (not DBG.isDeveloper()):
+ if os.path.isdir(tmp_working_dir) and (not debug.isDeveloper()):
shutil.rmtree(tmp_working_dir)
# Print again the path of the package
import os
import subprocess
-import re
+from gettext import gettext as _
import src
-import prepare
# Define all possible option for patch command : sat patch <options>
parser = src.options.Options()
# 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 re
import os
-import pprint as PP
+from gettext import gettext as _
import src
-import src.debug as DBG
# Define all possible option for prepare command : sat prepare <options>
import os
import subprocess
+from gettext import gettext as _
import src
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
+from gettext import gettext as _
import src
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import subprocess
+from gettext import gettext as _
import src
import os
import shutil
-import re
-import subprocess
+from gettext import gettext as _
import src
-import prepare
-import src.debug as DBG
+import src.debug as debug
# Define all possible option for patch command : sat patch <options>
parser = src.options.Options()
def run(args, runner, logger):
'''method that is called when salomeTools is called with source parameter.
'''
- DBG.write("source.run()", args)
+ debug.write("source.run()", args)
# Parse the options
(options, args) = parser.parse_args(args)
import subprocess
import fnmatch
import re
+from gettext import gettext as _
import src
# Python 2/3 compatibility for execfile function
try:
execfile
-except:
+except Exception:
def execfile(somefile, global_vars, local_vars):
with open(somefile) as f:
code = compile(f.read(), somefile, 'exec')
import subprocess
import datetime
import gzip
+from gettext import gettext as _
# Compatibility python 2/3 for input function
# input stays input for python 3 and input = raw_input for python 2
#shutil.rmtree(finalPath)
os.makedirs(finalPath)
pathIsOk = True
- except:
+ except Exception:
logger.error(_("%s cannot be created.") % finalPath)
finalPath = ask_a_path()
if os.access(tmp_dir, os.F_OK):
try:
shutil.rmtree(tmp_dir)
- except:
+ except Exception:
logger.error(_("error removing TT_TMP_RESULT %s\n")
% tmp_dir)
-
LOCAL :
{
base : 'default'
{
project_file_paths :
[
+ '/home/catA/gb262689/cea-projects/salome/sat_salome_fork_gb262689/salome.pyconf'
]
}
try:
__LANG__ = os.environ["LANG"] # original locale
-except:
+except Exception:
__LANG__ = "en_US.utf8" #default
__FR__={
if "FR" in __LANG__:
try:
return __FR__[text]
- except:
+ except Exception:
return text
return text
if __verbose__ is None:
try:
__verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
- except:
+ except Exception:
__verbose__ = 0
pass
pass
try:
builder.DefineComponentInstance( father, getEngine() )
pass
- except:
+ except Exception:
pass
pass
return father
if __verbose__ is None:
try:
__verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
- except:
+ except Exception:
__verbose__ = 0
pass
pass
try:
builder.DefineComponentInstance( father, getEngine() )
pass
- except:
+ except Exception:
pass
pass
return father
"""
import sys
-import debug as DBG
+import src.debug as debug
_versionPython = sys.version_info[0]
if _versionPython < 3:
# python2 previous historic mode
import src.ElementTreePython2 as etree
- DBG.write("ElementTree Python2 %s" % etree.VERSION, etree.__file__, DBG.isDeveloper())
+ debug.write("ElementTree Python2 %s" % etree.VERSION, etree.__file__, debug.isDeveloper())
tostring = etree.tostring
else:
# python3 mode
# import xml.etree.ElementTree as etree # native version
import src.ElementTreePython3 as etree # VERSION 1.3.0 plus _serialize 'pretty_xml'
- DBG.write("ElementTree Python3 %s" % etree.VERSION, etree.__file__, DBG.isDeveloper())
+ debug.write("ElementTree Python3 %s" % etree.VERSION, etree.__file__, debug.isDeveloper())
def tostring(node, encoding='utf-8'):
"""
"""
try:
aStr = etree.tostring(node, encoding='unicode', method="pretty_xml")
- except:
+ except Exception:
print("*****************************\n problem node", node)
# try no pretty
aStr = etree.tostring(node, encoding='unicode')
if items or xmlns_items:
try:
items = sorted(items) # lexical order
- except:
+ except Exception:
print("*** problem sorting items", items)
for k, v in items:
try:
for item in self._data:
try:
text += item
- except:
+ except Exception:
text += item.decode()
if self._tail:
assert self._last.tail is None, "internal error (tail)"
"""
try:
self._parser.Parse(data, 0)
- except:
+ except Exception:
print("*** problem feed:\n%s" % data.decode('utf-8'))
##
import io
import contextlib
-import ElementPath
+from src import ElementPath
class ParseError(SyntaxError):
close_source = True
try:
return _IterParseIterator(source, events, parser, close_source)
- except:
+ except Exception:
if close_source:
source.close()
raise
else:
self._root = self._parser._close_and_return_root()
self.root = self._root
- except:
+ except Exception:
if self._close_file:
self._file.close()
raise
on which SAT is running
'''
-import os, sys
+import os
+import sys
+from gettext import gettext as _
from platform import system,python_version,release
-# linux_distribution is removed from platform module in python 3.8+
-# we have to use distro module, which is not standard.
-# write an error message if distro is not installed
try:
- from platform import linux_distribution
-except:
- try:
- from distro import linux_distribution
- except:
- print ("\nError :\n"
- " linux_distribution was removed from platform module in Python 3.8+\n"
- " For python 3.8+ sat requires distro module to get information on linux distribution.\n"
- " Please install distro module with : pip install distro")
- sys.exit(-1)
+ from distro import distro
+except Exception:
+ print ("\nError :\n"
+ " linux_distribution was removed from platform module in Python 3.8+\n"
+ " For python 3.8+ sat requires distro module to get information on linux distribution.\n"
+ " Please install distro module with : pip install distro")
+ sys.exit(1)
def is_windows():
return "W"
# else get linux distribution description from platform, and encode it with code
- lin_distrib = linux_distribution()[0].lower()
+ lin_distrib = distro.id().lower()
distrib="not found"
for dist in codes:
if dist in lin_distrib:
from a CentOS example, returns '7.6'
extracted from platform.linux_distribution()
"""
- dist_version=linux_distribution()[1].split('.')
+ dist_version=distro.version().split('.')
if len(dist_version)==1:
version = dist_version[0]
else:
return release()
# get version from platform
- dist_version=linux_distribution()[1].split('.')
+ dist_version=distro.version().split('.')
# encode it (conform to src/internal_config/distrib.pyconf VERSIONS dist
if distrib == "CO":
import os
import sys
import inspect
-import logging
-import pprint as PP
##############################################################################
if namesrc == "__main__":
namesrc = os.path.basename(fr.f_globals["__file__"])
lineno.insert(0, (namesrc + "[%s]" % fr.f_lineno))
- except:
+ except Exception:
lineno.insert(0, ("??", fr.f_lineno))
if codename != '<module>': # top level usually
import sys
import shutil
import glob
+from gettext import gettext as _
import src
pymodule = imp.load_source(product + "_compile_script", script)
self.nb_proc = nb_proc
retcode = pymodule.compil(self.config, self, self.logger)
- except:
+ except Exception:
__, exceptionValue, exceptionTraceback = sys.exc_info()
self.logger.write(str(exceptionValue), 1)
import traceback
import traceback
import pprint as PP
import inspect
-import src
# Compatibility python 2/3 for unicode
try:
_test = unicode
-except:
+except Exception:
unicode = str
# Compatibility python 2/3 for StringIO
try: #type config, mapping
order = object.__getattribute__(config, 'order')
data = object.__getattribute__(config, 'data')
- except:
+ except Exception:
aStream.write("%s%s : '%s'\n" % (indstr, path, str(config)))
return
for key in sorted(data): #order): # data as sort alphabetical, order as initial order
import copy
import src
-import src.debug as DBG
+import src.debug as debug
import pprint as PP
for k in self.environ.environ.keys():
try:
value = self.get(k)
- except:
+ except Exception:
value = "?"
out.write("%s=%s\n" % (k, value))
:param product_info Config: The product description
:param logger Logger: The logger instance to display messages
"""
- DBG.write("set_salome_minimal_product_env", product_info)
+ debug.write("set_salome_minimal_product_env", product_info)
# set root dir
root_dir = product_info.name + "_ROOT_DIR"
# not mandatory, if set_nativ_env not defined, we do nothing
if "set_nativ_env" in dir(pyproduct):
pyproduct.set_nativ_env(self)
- except:
+ except Exception:
__, exceptionValue, exceptionTraceback = sys.exc_info()
print(exceptionValue)
import traceback
:param logger Logger: The logger instance to display messages
:param env_info list: the list of products
"""
- DBG.write("set_full_environ for", env_info)
+ debug.write("set_full_environ for", env_info)
# DBG.write("set_full_environ config", self.cfg.APPLICATION.environ, True)
# set product environ
self.set_application_env(logger)
import os
import pprint as PP
-import src.debug as DBG
+import src.debug as debug
import src.architecture
import src.environment
try:
statinfo = os.stat(os.path.join(tmp_dir, file_name))
currentTime = statinfo.st_mtime
- except:
+ except Exception:
pass
if currentTime and currentTime > beginTime:
import gettext
import unittest
+_ = gettext.gettext
+
verbose = False
class TestCase(unittest.TestCase):
import re
import tempfile
import shutil
+from gettext import gettext as _
import src
-import printcolors
-import xmlManager
-
-import src.debug as DBG
+import src.xmlManager as xmlManager
+import src.printcolors as printcolors
+import src.debug as debug
log_macro_command_file_expression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$"
log_all_command_file_expression = "^.*[0-9]{8}_+[0-9]{6}_+.*\.xml$"
:param silent_sysstd boolean: if True, do not write anything
in terminal.
"""
- DBG.write("src.logger.Logger", id(self))
+ debug.write("src.logger.Logger", id(self))
self.config = config
self.default_level = 3
self.silentSysStd = silent_sysstd
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)
_currentLogger[0] = logger
- logger.warning("change current logger as %s" % logger.name)
+ # logger.warning("change current logger as %s" % logger.name)
return _currentLogger[0]
def isCurrentLoggerUnittest():
from logging.handlers import BufferingHandler
import pprint as PP
-import src.debug as DBG # Easy print stderr (for DEBUG only)
+import src.debug as debug # Easy print stderr (for DEBUG only)
_verbose = False
_name = "loggingSimple"
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
- except:
+ except Exception:
self.handleError(record)
import sys
import re
import pprint as PP
+from gettext import gettext as _
from . import printcolors
-import src
-import src.debug as DBG # Easy print stderr (for DEBUG only)
+import src.debug as debug
class OptResult(object):
"""
if argList is None:
argList = sys.argv[1:]
- DBG.write("parse_args", argList)
+ debug.write("parse_args", argList)
# DBG.write("options", self.options)
# format shortNameOption and longNameOption
# to make right arguments to getopt.getopt function
option['result'] = None
self.results = {"optlist": optlist, "optResult": optResult, "args": args, "argList": argList}
- DBG.write("results", self.results)
+ debug.write("results", self.results)
return optResult, args
def filterLevel(self, aLevel):
"""filter level logging values"""
- import src.loggingSimple as LOG
+ import src.loggingSimple as log
aLev = aLevel.upper()
- knownLevels = LOG._knownLevels
+ knownLevels = log._knownLevels
maxLen = max([len(i) for i in knownLevels])
for i in range(maxLen):
for lev in knownLevels:
if aLev == lev[:i]:
- DBG.write("filterLevel", "%s -> %s" % (aLevel, lev))
+ debug.write("filterLevel", "%s -> %s" % (aLevel, lev))
return lev
msg = "Unknown level '%s', accepted are:\n%s" % (aLev, ", ".join(knownLevels))
raise Exception(msg)
return res
def debug_write(self):
- DBG.write("options and results", self, True)
+ debug.write("options and results", self, True)
import pprint as PP
import src
-import src.debug as DBG
+import src.debug as debug
import src.versionMinorMajorPatch as VMMP
AVAILABLE_VCS = ['git', 'svn', 'cvs']
script_path = src.find_file_in_lpath(script_name, config.PATHS.PRODUCTPATH, "compil_scripts")
if not script_path:
msg = _("Compilation script %s not found in") % script_name
- DBG.tofix(msg, config.PATHS.PRODUCTPATH, True) # say where searched
+ debug.tofix(msg, config.PATHS.PRODUCTPATH, True) # say where searched
script_path = "%s_(Not_Found_by_Sat!!)" % script_name
prod_info.compil_script = script_path
# Check that the script is executable
if os.path.exists(prod_info.compil_script) and not os.access(prod_info.compil_script, os.X_OK):
- DBG.tofix("Compilation script file is not in 'execute mode'", prod_info.compil_script, True)
+ debug.tofix("Compilation script file is not in 'execute mode'", prod_info.compil_script, True)
# If the product has a post install script, check the script existence
# and if it is executable
script_path = src.find_file_in_lpath(script_name, config.PATHS.PRODUCTPATH, "post_scripts")
if not script_path:
msg = _("Post install script %s not found in") % script_name
- DBG.tofix(msg, config.PATHS.PRODUCTPATH, True) # say where searched
+ debug.tofix(msg, config.PATHS.PRODUCTPATH, True) # say where searched
script_path = "%s_(Not_Found_by_Sat!!)" % script_name
prod_info.post_script = script_path
# Check that the script is executable
if os.path.exists(prod_info.post_script) and not os.access(prod_info.post_script, os.X_OK):
- DBG.tofix("Post install script file is not in 'execute mode'", prod_info.post_script, True)
+ debug.tofix("Post install script file is not in 'execute mode'", prod_info.post_script, True)
# Get the full paths of all the patches
if product_has_patches(prod_info):
"prod_name" : prod_info.name})
raise src.SatException(msg)
patches.append(patch_path)
- except:
- DBG.tofix("problem in prod_info.patches", prod_info)
+ except Exception:
+ debug.tofix("problem in prod_info.patches", prod_info)
prod_info.patches = patches
# Get the full paths of the environment scripts
# decode version number
try:
versionMMP = VMMP.MinorMajorPatch(version)
- except: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'"
+ except Exception: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'"
versionMMP = None
# if a section is explicitely specified we select it
tagged.append((name, [vmin, vmax]))
if len(tagged) > 1:
- DBG.write("multiple version ranges tagged for '%s', fix it" % version,
+ debug.write("multiple version ranges tagged for '%s', fix it" % version,
PP.pformat(tagged))
pi=None
elif len(tagged) == 1: # ok
try:
with open(aFile, 'w') as f:
p_info.__save__(f, evaluated=True) # evaluated expressions mode
- except:
+ except Exception:
# sometime some information cannot be evaluated.
# for example, in the context of non VCS archives, information on git server is not available.
- DBG.write("Warning : sat was not able to evaluate and write down some information in file %s" % aFile)
+ debug.write("Warning : sat was not able to evaluate and write down some information in file %s" % aFile)
def check_config_exists(config, prod_dir, prod_info, verbose=False):
else:
raise Exception("Inexisting directory '%s'" % prod_dir)
- DBG.write("check_config_exists 000", (prod_dir, l_dir_and_files), verbose)
- DBG.write("check_config_exists 111", prod_info, verbose)
+ debug.write("check_config_exists 000", (prod_dir, l_dir_and_files), verbose)
+ debug.write("check_config_exists 111", prod_info, verbose)
depend_all=[]
if "depend" in prod_info:
# directory
afilename = CONFIG_FILENAME + prod_info.name + ".pyconf"
config_file = os.path.join(prod_dir, dir_or_file, afilename)
- DBG.write("check_config_exists 222", config_file, verbose)
+ debug.write("check_config_exists 222", config_file, verbose)
if not os.path.exists(config_file):
continue
# assume new compatibility with prod_name in sat-config.pyconf files
if prod_name == prod_info.name:
if prod_info.version == compile_cfg[prod_name]:
- DBG.write("check_config_exists OK 333", compile_cfg, verbose)
+ debug.write("check_config_exists OK 333", compile_cfg, verbose)
pass
else: # no correspondence with newer with prod_name sat-config.pyconf files
config_corresponds = False
break
if config_corresponds: # returns (and stops) at first correspondence found
- DBG.write("check_config_exists OK 444", dir_or_file, verbose)
+ debug.write("check_config_exists OK 444", dir_or_file, verbose)
return True, os.path.join(prod_dir, dir_or_file)
# no correspondence found
else:
res.append((p_name, p_info))
ok.append(p_name)
- except:
+ except Exception:
res.append((p_name, p_info))
ok.append(p_name)
else:
ok.append(p_name)
else:
ko.append(p_name)
- except:
+ except Exception:
ko.append(p_name)
if len(ok) != len(resAll):
"""
dev = product_info.dev
res = (dev.lower() == 'yes')
- DBG.write('product_is_dev %s' % product_info.name, res)
+ debug.write('product_is_dev %s' % product_info.name, res)
# if product_info.name == "XDATA": return True #test #10569
return res
try:
has_utf32 = True
-except:
+except Exception:
has_utf32 = False
class ConfigInputStream(object):
rv = eval(str(self)[1:-1], vars(ns))
found = True
break
- except:
+ except Exception:
pass
if found:
break
key = item[1]
rv = rv[key]
break
- except:
+ except Exception:
rv = None
pass
current = object.__getattribute__(current, 'parent')
continue
try:
exec( 'map1.' + key + " = " + repr(overwrite_instruction[key]))
- except:
+ except Exception:
exec('map1.' + key + " = " + str(overwrite_instruction[key]))
else:
for key in overwrite_instruction.keys():
try:
exec('map1.' + key + " = " + repr(overwrite_instruction[key]))
- except:
+ except Exception:
exec('map1.' + key + " = " + str(overwrite_instruction[key]))
def mergeMapping(self, map1, map2):
"""return system return code as bash or bat"""
try:
return self._TOSYS[self._status]
- except:
+ except Exception:
return self._TOSYS[self.NA_STATUS]
def toXmlPassed(self):
# 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 sys
+from gettext import gettext as _
+import os
+import re
+import tempfile
+import imp
+import types
+import gettext
+
+import src
+import src.debug as debug # Easy print stderr (for DEBUG only)
+import src.returnCode as RCO # Easy (ok/ko, why) return methods code
+import src.utilsSat as UTS
+
"""
This file is the main API file for salomeTools
| Usage: see file ../sat
"""
-import sys
-
# exit OKSYS and KOSYS seems equal on linux or windows
_OKSYS = 0 # OK
_KOSYS = 1 # KO
sys.stderr.write(msg)
sys.exit(_KOSYS)
-# python imports
-import os
-import re
-import tempfile
-import imp
-import types
-import gettext
-import traceback
-
-import src
-import src.debug as DBG # Easy print stderr (for DEBUG only)
-import src.returnCode as RCO # Easy (ok/ko, why) return methods code
-import src.utilsSat as UTS
# get path to salomeTools sources
satdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
try:
_LANG = os.environ["LANG"] # original locale
-except:
+except Exception:
_LANG = "en_US.utf8" #default
# The possible hooks :
"""force english at any moment"""
os.environ["LANG"] = ''
gettext.install("salomeTools", os.path.join(srcdir, "i18n"))
- DBG.write("setNotLocale", os.environ["LANG"])
+ debug.write("setNotLocale", os.environ["LANG"])
def setLocale():
"""
"""
os.environ["LANG"] = _LANG
gettext.install("salomeTools", os.path.join(srcdir, "i18n"))
- DBG.write("setLocale", os.environ["LANG"])
+ debug.write("setLocale", os.environ["LANG"])
def getVersion():
"""get version number as string"""
"""set the commands by calling the dedicated function etc..."""
options, remaindersArgs = parser.parse_args(opt)
if options.debug_mode:
- DBG.push_debug(True)
+ debug.push_debug(True)
self.arguments = opt
self.options = options # the generic options passed to salomeTools
self.remaindersArgs = remaindersArgs # the command and their options
self.datadir = datadir # default value will be <salomeTools root>/data
self._setCommands(cmdsdir)
- DBG.write("Sat.options", self.options, self.options.debug_mode)
+ debug.write("Sat.options", self.options, self.options.debug_mode)
def getConfig(self):
return self.cfg
self.mainLogger.info(get_help())
return RCO.ReturnCode("OK", "help done")
- DBG.write("options", self.options)
- DBG.write("remaindersArgs", self.remaindersArgs)
+ debug.write("options", self.options)
+ debug.write("remaindersArgs", self.remaindersArgs)
if len(self.remaindersArgs) == 0:
return RCO.ReturnCode("KO", "Nothing to do")
# Run the command using the arguments
code = fun_command(self.remaindersArgs[1:])
- if code is None: code = 0 # what?! do not know why so respect history
+ if code is None:
+ code = 0
# return salomeTools command with the right message
# code (0 if no errors, else 1)
sys.stderr = ff
import paramiko
sys.stderr = saveout
- except:
+ except Exception:
sys.stderr = saveout
continue
# load the module that has name nameCmd in dirPath
(file_, pathname, description) = imp.find_module(nameCmd, [dirPath])
module = imp.load_module(nameCmd, file_, pathname, description)
+ file_.close()
def run_command(args='',
options=None,
logger_command.write(" *****\n", 1)
print(e.message)
if self.options.debug_mode:
- logger_command.write("\n" + DBG.format_exception("") + "\n", 1)
+ logger_command.write("\n" + debug.format_exception("") + "\n", 1)
except Exception as e:
# here we print the stack in addition
logger_command.write(src.printcolors.printcError(
"salomeTools ERROR: sat %s" % __nameCmd__), 1)
- logger_command.write("\n" + DBG.format_exception("") + "\n", 1)
+ logger_command.write("\n" + debug.format_exception("") + "\n", 1)
finally:
# load the module
(file_, pathname, description) = imp.find_module(module, [cmdsdir])
module = imp.load_module(module, file_, pathname, description)
+ file_.close()
return module
##################################################################
import subprocess as SP
import time
import tarfile
-import time
+from gettext import gettext as _
-
-import debug as DBG
-import utilsSat as UTS
import src
+from . import utilsSat as UTS
+from . import debug
from . import printcolors
def show_in_editor(editor, filePath, logger):
logger.write('Launched command:\n' + cmd + '\n', 5)
p = SP.Popen(cmd, shell=True)
p.communicate()
- except:
+ except Exception:
logger.write(printcolors.printcError(_("Unable to edit file %s\n")
% filePath), 1)
'''Use git describe --tags command to return tag description of the git repository"
:param repo_path str: The git repository to describe
'''
- git_cmd="cd %s;git describe --tags" % repo_path
+ git_cmd=f"cd {repo_path};git describe --tags"
p = SP.Popen(git_cmd, shell=True, stdin=SP.PIPE, stdout=SP.PIPE, stderr=SP.PIPE)
p.wait()
if p.returncode != 0:
:return: True if the extraction is successful
:rtype: boolean
'''
- DBG.write("git_extract", [from_what, tag, str(where)])
+ debug.write("git_extract", [from_what, tag, str(where)])
if not where.exists():
where.make()
where_git = os.path.join(str(where), ".git")
logger.logTxtFile.write("\n" + cmd + "\n")
logger.logTxtFile.flush()
- DBG.write("cmd", cmd)
+ debug.write("cmd", cmd)
# git commands may fail sometimes for various raisons
# (big module, network troubles, tuleap maintenance)
# therefore we give several tries
'parentWhere': parentWhere,
'tmpWhere': tmpWhere,
}
- DBG.write("git_extract_sub_dir", aDict)
+ debug.write("git_extract_sub_dir", aDict)
if not src.architecture.is_windows():
cmd = r"""
set -x
rm -rf $tmpDir
""" % aDict
- DBG.write("cmd", cmd)
+ debug.write("cmd", cmd)
for nbtry in range(0,3): # retries case of network problem
rc = UTS.Popen(cmd, cwd=parentWhere, env=environment.environ.environ, logger=logger)
try:
output = SP.check_output(['grep', pkg], stdin=p.stdout)
msg_status=src.printcolors.printcSuccess("OK")
- except:
+ except Exception:
msg_status=src.printcolors.printcError("KO")
msg_status+=" (package is not installed!)\n"
elif check_cmd[0] == "dpkg-query":
# Python 2/3 compatibility for execfile function
try:
execfile
-except:
+except Exception:
def execfile(somefile, global_vars, local_vars):
with open(somefile) as f:
code = compile(f.read(), somefile, 'exec')
if 'time' in ldic:
try:
exec_time = float(ldic['time'])
- except:
+ except Exception:
pass
results[test] = [status, exec_time, callback, expected]
- except:
+ except Exception:
results[test] = ["?", -1, "", []]
# results[test] = [src.O_STATUS, -1, open(resfile, 'r').read(), []]
try:
grid = imp.load_module(sal_uts, file_, pathname, description)
return grid.getLogDir
- except:
+ except Exception:
grid = imp.load_module(sal_uts, file_, pathname, description)
return grid.getTmpDir
finally:
try:
ii = int(res[0])
- except:
+ except Exception:
msg = "major in major_minor_patch is not integer: '%s'" % aStr
raise Exception(msg)
if ii < 0:
try:
ii = int(res[1])
- except:
+ except Exception:
msg = "minor in major_minor_patch is not integer: '%s'" % aStr
raise Exception(msg)
if ii < 0:
try:
ii = int(res[2])
- except:
+ except Exception:
msg = "patch in major_minor_patch is not integer: '%s'" % aStr
raise Exception(msg)
if ii < 0:
try:
rMin = MinorMajorPatch(aMin)
rMax = MinorMajorPatch(aMax)
- except:
+ except Exception:
msg = "problem version range in '%s'" % aStr
raise Exception(msg)
"""if verbose:
import sys
reload(sys)
sys.setdefaultencoding('utf8')
-except:
+except Exception:
pass
import src