if reinitialise_paths:
context.setVariable('SalomeAppConfig', gui_res_dir, overwrite=True)
else:
- context.addToPath('SalomeAppConfig', gui_res_dir, separator=':')
+ context.addToVariable('SalomeAppConfig', gui_res_dir, separator=':')
context.setVariable('PARALLEL_VISU', '1', overwrite=True)
geom_res_dir = os.path.join(geom_root_dir, 'share', 'salome', 'resources', 'geom')
- context.addToPath('SalomeAppConfig', geom_res_dir, separator=':')
+ context.addToVariable('SalomeAppConfig', geom_res_dir, separator=':')
context.setVariable('GEOM_PluginsList',
'BREPPlugin:STEPPlugin:IGESPlugin:STLPlugin:XAOPlugin:VTKPlugin:AdvancedGEOM',
overwrite=True)
context.addToPythonPath(os.path.join(pyhello_root_dir, 'bin', 'salome'))
context.addToPythonPath(os.path.join(pyhello_root_dir, 'lib', 'salome'))
context.addToPythonPath(os.path.join(pyhello_root_dir, python_libdir, 'salome'))
- context.addToPath('SALOME_MODULES', 'PYHELLO', separator=',')
+ context.addToVariable('SALOME_MODULES', 'PYHELLO', separator=',')
pyhello_res_dir = os.path.join(pyhello_root_dir, 'share', 'salome', 'resources', 'pyhello')
- context.addToPath('SalomeAppConfig', pyhello_res_dir, separator=':')
+ context.addToVariable('SalomeAppConfig', pyhello_res_dir, separator=':')
context.addToVariable('SMESH_MeshersList', 'StdMeshers', separator=':')
smesh_res_dir = os.path.join(smesh_root_dir, 'share', 'salome', 'resources', 'smesh')
- context.addToPath('SalomeAppConfig', smesh_res_dir, separator=':')
+ context.addToVariable('SalomeAppConfig', smesh_res_dir, separator=':')
#[gmsh]
gmsh_root_dir = os.path.join(root_dir, 'gmsh')
netgenplugin_res_dir = os.path.join(netgenplugin_root_dir,
'share', 'salome', 'resources', 'netgenplugin')
- context.addToPath('SalomeAppConfig', netgenplugin_res_dir, separator=':')
+ context.addToVariable('SalomeAppConfig', netgenplugin_res_dir, separator=':')
import json
from traceback import format_exc
-# Setup logger's output
-FORMAT = '%(funcName)s():%(lineno)s: %(message)s'
-logging.basicConfig(format=FORMAT, level=logging.DEBUG)
logger = logging.getLogger()
SALOME_EXTDIR = '__SALOME_EXT__'
salomeappname = "SalomeApp"
script_nam = "pyscript"
verbosity_nam = "verbosity"
+on_demand_nam = "on_demand"
# possible choices for the "embedded" and "standalone" parameters
embedded_choices = [ "registry", "study", "moduleCatalog", "cppContainer", "SalomeAppEngine" ]
# values of boolean type (must be '0' or '1').
# xml_parser.boolValue() is used for correct setting
-boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam, launcher_only_nam )
+boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam, launcher_only_nam, on_demand_nam )
intKeys = ( interp_nam, )
strKeys = ( launcher_nam )
default="0",
help=help_str)
+ # On demand
+ help_str = "Use installed salome on-demand extensions."
+ help_str += "0 to run without salome extensions [default], "
+ help_str += "1 to run only installed salome extensions. "
+ pars.add_argument("--on-demand",
+ dest="on_demand",
+ metavar="<0/1>",
+ action=StoreBooleanAction,
+ default=False,
+ help=help_str)
+
# Positional arguments (hdf file, python file)
pars.add_argument("arguments", nargs=argparse.REMAINDER)
args[script_nam] = new_args
args[verbosity_nam] = cmd_opts.verbosity
+ args[on_demand_nam] = cmd_opts.on_demand
# xterm
if cmd_opts.xterm is not None:
import runSalomeNoServer
import runSalomeCommon
import platform
+import runSalomeOnDemand
+from launchConfigureParser import verbosity_nam, on_demand_nam
import logging
logger = logging.getLogger()
mySessionServ.run()
ior_fakens_filename = mySessionServ.iorfakens
logger.debug("Rendez-vous file for to retrieve IOR of session is \"{}\"".format(ior_fakens_filename))
-
+
end_time = os.times()
#
"""Salome launch as a main application"""
keep_env = not os.getenv('SALOME_PLEASE_SETUP_ENVIRONMENT_AS_BEFORE')
args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName, keepEnvironment=keep_env)
- runSalomeCommon.setVerbose(args["verbosity"])
+ runSalomeCommon.setVerbose(args[verbosity_nam])
+
kill_salome(args)
# --
+
+ # Setup extension's env in salome on demand case
+ if args[on_demand_nam]:
+ runSalomeOnDemand.set_ext_env()
+
setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
ior_fakens_filename = useSalome(args, modules_list, modules_root_dir)
# Management of -t <script.py>
proc = subprocess.Popen(command, shell=True, env = env)
addToKillList(proc.pid, command)
res = proc.wait()
- if res: sys.exit(1)
+ if res: sys.exit(1)
return args, ior_fakens_filename
# -----------------------------------------------------------------------------
from salomeContextUtils import ScriptAndArgsObjectEncoder
import platform
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)
logger = logging.getLogger()
class ColoredFormatter(logging.Formatter):
return logging.Formatter.format(self, record)
def setVerbose(verbose):
- from packaging import version
- current_version = version.parse("{}.{}".format(sys.version_info.major,sys.version_info.minor))
- version_ref = version.parse("3.5.0")
- global logger
- formatter = None
- if current_version >= version_ref:
- formatter = BackTraceFormatter('%(levelname)s : %(asctime)s : %(message)s ',style='%')
- else:
- formatter = logging.Formatter('%(levelname)s : %(asctime)s : %(message)s ',style='%')
- formatter.default_time_format = '%H:%M:%S'
- formatter.default_msec_format = "%s.%03d"
- stream_handler = logging.StreamHandler()
- stream_handler.setFormatter(formatter)
- logger.addHandler(stream_handler)
+ # from packaging import version
+ # current_version = version.parse("{}.{}".format(sys.version_info.major,sys.version_info.minor))
+ # version_ref = version.parse("3.5.0")
+ # global logger
+ # formatter = None
+ # if current_version >= version_ref:
+ # formatter = BackTraceFormatter('%(levelname)s : %(asctime)s : %(message)s ',style='%')
+ # else:
+ # formatter = logging.Formatter('%(levelname)s : %(asctime)s : %(message)s ',style='%')
+ # formatter.default_time_format = '%H:%M:%S'
+ # formatter.default_msec_format = "%s.%03d"
+ # stream_handler = logging.StreamHandler()
+ # stream_handler.setFormatter(formatter)
+ # logger.addHandler(stream_handler)
verbose_map = { "0": logging.WARNING, "1": logging.INFO, "2": logging.DEBUG}
if verbose in verbose_map:
@abc.abstractmethod
def getSessionServerExe(self):
pass
-
+
def setpath(self,modules_list,modules_root_dir):
list_modules = modules_list[:]
list_modules.reverse()
super().__init__(args,modules_list,modules_root_dir)
import KernelBasis
KernelBasis.setSSLMode(False)
-
+
def getSessionServerExe(self):
return "SALOME_Session_Server"
# ---
import sys
import importlib.util
from pathlib import Path
-import runSalome
import salomeContext
from SalomeOnDemandTK.extension_utilities import logger, \
DFILE_EXT, SALOME_EXTDIR, \
return module
-def set_ext_env(app_name, version):
+def set_ext_env(app_name='', version=''):
"""
Set an environment to start SALOME as a set of extensions.
logger.debug('Set an env for app: %s, version: %s...', app_name, version)
# Get the root directory
- levels_up = 2
+ levels_up = 4
app_root = str(Path(__file__).resolve().parents[levels_up - 1])
logger.debug('App root: %s', app_root)
if __name__ == "__main__":
if len(sys.argv) == 3:
- arg_1, arg_2 = sys.argv[1:] # pylint: disable=unbalanced-tuple-unpacking
+ arg_1, arg_2 = sys.argv[1:]
set_ext_env(arg_1, arg_2)
-
- runSalome.runSalome()
else:
logger.error('You must provide all the arguments!')
logger.info(set_ext_env.__doc__)