From: Konstantin Leontev Date: Fri, 30 Dec 2022 17:08:05 +0000 (+0300) Subject: [bos #32522][EDF] SALOME on Demand. Added set SALOME_APPLICATION_DIR env, queryinstal... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7f87691cf433eb8372fe3b66879a48fef243d1b;p=modules%2Fkernel.git [bos #32522][EDF] SALOME on Demand. Added set SALOME_APPLICATION_DIR env, queryinstalled extensions info, logging format. --- diff --git a/bin/SalomeOnDemandTK/extension_query.py b/bin/SalomeOnDemandTK/extension_query.py index 600a9d30a..dbcea88ee 100644 --- a/bin/SalomeOnDemandTK/extension_query.py +++ b/bin/SalomeOnDemandTK/extension_query.py @@ -260,6 +260,33 @@ def dependency_tree(directory): return tree +def ext_info_dict(directory): + r""" + Get installed salome extensions info. + + Args: + directory - the given ext install directory. + + Returns: + A dictionary {name: size}. + """ + + logger.debug('Build info dictionary for extensions in %s', directory) + + ext_info = {} + salomexd_files = list_files_ext(directory, DFILE_EXT) + logger.debug('There are %s extensions in %s', len(salomexd_files), directory) + + for salomexd_file in salomexd_files: + ext_name, _ = os.path.splitext(os.path.basename(salomexd_file)) + size = ext_size_str(directory, ext_name) + + ext_info[ext_name] = size + + logger.debug('Installed extensions info: %s', ext_info) + return ext_info + + if __name__ == '__main__': if len(sys.argv) == 2: dir_size_str(sys.argv[1]) diff --git a/bin/SalomeOnDemandTK/extension_utilities.py b/bin/SalomeOnDemandTK/extension_utilities.py index f60c80efd..ae2dc6ccb 100644 --- a/bin/SalomeOnDemandTK/extension_utilities.py +++ b/bin/SalomeOnDemandTK/extension_utilities.py @@ -37,6 +37,10 @@ import logging import json from traceback import format_exc +# 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) logger = logging.getLogger() SALOME_EXTDIR = '__SALOME_EXT__' diff --git a/bin/runSalomeOnDemand.py b/bin/runSalomeOnDemand.py index 47351851b..69d48b00f 100755 --- a/bin/runSalomeOnDemand.py +++ b/bin/runSalomeOnDemand.py @@ -98,8 +98,11 @@ def set_ext_env(app_name='', version=''): logger.debug('There are not any extensions in %s!', app_root) return - # Execute env file as a module + # Set the root dir as env variable context = salomeContext.SalomeContext(None) + context.setVariable('SALOME_APPLICATION_DIR', app_root, overwrite=True) + + # Execute env file as a module ext_root = os.path.join(app_root, SALOME_EXTDIR) for salomexd in installed_ext: salomexd_name = os.path.basename(salomexd)