From: Konstantin Leontev Date: Thu, 23 Feb 2023 11:07:14 +0000 (+0300) Subject: [bos #32522][EDF] SALOME on Demand. Fixed python linter issues for 3.7 version. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f4d0d647f731f21feac7e24213e63a4f1d8f4f3;p=modules%2Fkernel.git [bos #32522][EDF] SALOME on Demand. Fixed python linter issues for 3.7 version. --- diff --git a/bin/SalomeOnDemandTK/extension_unpacker.py b/bin/SalomeOnDemandTK/extension_unpacker.py index 4590c2908..08b45d40f 100644 --- a/bin/SalomeOnDemandTK/extension_unpacker.py +++ b/bin/SalomeOnDemandTK/extension_unpacker.py @@ -76,6 +76,10 @@ def unpack_salomex(salome_root, salomex): logger.debug('Try to read %s.%s file...', salome_ext_name, DFILE_EXT) salomexd_mem = ext.getmember(salome_ext_name + '.' + DFILE_EXT) salomexd_file = ext.extractfile(salomexd_mem) + if not salomexd_file: + logger.error('Cannot extract %s.%s file!', salome_ext_name, DFILE_EXT) + return False + salomexd_content = json.load(salomexd_file) logger.debug('Check dependencies...') diff --git a/bin/SalomeOnDemandTK/extension_utilities.py b/bin/SalomeOnDemandTK/extension_utilities.py index 81069b2e0..2a5b72864 100644 --- a/bin/SalomeOnDemandTK/extension_utilities.py +++ b/bin/SalomeOnDemandTK/extension_utilities.py @@ -45,7 +45,7 @@ import re # Usually logging verbosity is set inside bin/runSalomeCommon.py when salome is starting. # Here we do just the same for a case if we call this package stand alone. FORMAT = '%(levelname)s : %(asctime)s : [%(filename)s:%(funcName)s:%(lineno)s] : %(message)s' -logging.basicConfig(format=FORMAT, level=logging.DEBUG, force=False) +logging.basicConfig(format=FORMAT, level=logging.DEBUG) logger = logging.getLogger() # SalomeContext sets the logging verbosity level on its own, @@ -570,6 +570,10 @@ def module_from_filename(filename): sys.modules[module_name] = module logger.debug('Execute %s module', module_name) + if not spec.loader: + logger.error('spec.loader is None for %s file!') + return None + spec.loader.exec_module(module) return module @@ -592,7 +596,7 @@ def set_selext_env(install_dir, salomex_name, context=None): # Set the root dir as env variable if not context: - context = salomeContext.SalomeContext(None) + context = salomeContext.SalomeContext(0) context.setVariable('SALOME_APPLICATION_DIR', install_dir, overwrite=False) # Find env file diff --git a/bin/runSalomeCommon.py b/bin/runSalomeCommon.py index 63b3c8d8d..b0d307d3f 100755 --- a/bin/runSalomeCommon.py +++ b/bin/runSalomeCommon.py @@ -38,7 +38,7 @@ import logging # Setting formatter in setVerbose() was commented because adding of handler # breaks using of root logger in other modules and cause many double lines in logs. FORMAT = '%(levelname)s : %(asctime)s : [%(filename)s:%(funcName)s:%(lineno)s] : %(message)s' -logging.basicConfig(format=FORMAT, force=True) +logging.basicConfig(format=FORMAT) logger = logging.getLogger() class ColoredFormatter(logging.Formatter): diff --git a/bin/runSalomeOnDemand.py b/bin/runSalomeOnDemand.py index 1326dd827..1117b6a51 100755 --- a/bin/runSalomeOnDemand.py +++ b/bin/runSalomeOnDemand.py @@ -62,7 +62,7 @@ def set_ext_env(app_name='', version=''): return # Set the root dir as env variable - context = salomeContext.SalomeContext(None) + context = salomeContext.SalomeContext(0) context.setVariable('SALOME_APPLICATION_DIR', app_root, overwrite=True) # Execute env file as a module