From: Anthony Geay Date: Wed, 23 Feb 2022 09:45:52 +0000 (+0100) Subject: Management of : X-Git-Tag: V9_9_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d2cad0f565b5c83ce4d823b757f57d1c78f13e9d;p=modules%2Fkernel.git Management of : - salome -t - salome -l - fix problem of KERNEL_UnitTest --- diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 5375452df..04e6939f6 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -65,6 +65,8 @@ import psutil from salome_utils import (generateFileName, getHostName, getLogDir, getShortHostName, getUserName, killOmniNames, killPid, verbose) +import logging +logger = logging.getLogger() def getPiDict(port, appname='salome', full=True, hidden=True, hostname=None): """ @@ -247,6 +249,7 @@ def __killPids(pids): processes = [] for pid in pids: try: + logger.debug("Add process with PID = {} into PIDList to kill".format(pid)) processes.append(psutil.Process(pid)) except psutil.NoSuchProcess: if verbose(): @@ -262,7 +265,7 @@ def __killMyPort(port, filedict): # ensure port is an integer with suppress(ValueError): port = int(port) - + logger.debug("Into __killMyPort with port {}. File containing PID to kill is {}".format(port,filedict)) # read pids from pidict file with suppress(Exception), open(filedict, 'rb') as fpid: pids_lists = pickle.load(fpid) diff --git a/bin/runSalome.py b/bin/runSalome.py index 20f3da436..422631b68 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -80,6 +80,7 @@ def startSalome(args, modules_list, modules_root_dir): mySessionServ.setpath(modules_list,modules_root_dir) 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() @@ -106,7 +107,7 @@ def startSalome(args, modules_list, modules_root_dir): logger.debug("additional external python interpreters: {}".format(nbaddi)) if nbaddi: for i in range(nbaddi): - anInterp=InterpServer(args) + anInterp=runSalomeCommon.InterpServer(args) anInterp.run() # set PYTHONINSPECT variable (python interpreter in interactive mode) @@ -174,7 +175,7 @@ def addToPidict(args): global process_id from addToKillList import addToKillList for pid, cmd in list(process_id.items()): - addToKillList(pid, cmd, args['port']) + addToKillList(pid, cmd) # ----------------------------------------------------------------------------- @@ -187,6 +188,26 @@ def main(exeName=None): # -- 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 + toimport = [] + if 'gui' in args and 'session_gui' in args: + if not args['gui'] or not args['session_gui']: + if 'study_hdf' in args: + toopen = args['study_hdf'] + if toopen: + import salome + salome.salome_init(path=toopen) + if 'pyscript' in args: + toimport = args['pyscript'] + from salomeContextUtils import formatScriptsAndArgs + from addToKillList import addToKillList + command = formatScriptsAndArgs(toimport, escapeSpaces=True) + if command: + logger.debug("Launching following shell command : {}".format(str(command))) + proc = subprocess.Popen(command, shell=True) + addToKillList(proc.pid, command) + res = proc.wait() + if res: sys.exit(1) return args, ior_fakens_filename # ----------------------------------------------------------------------------- @@ -273,12 +294,14 @@ def foreGround(args, ior_fakens_filename): status = session.GetStatSession() assert status.activeGUI except Exception: + logger.debug("Process of the session under monitoring {} has vanished !".format(session_pid)) break from time import sleep sleep(dt) pass pass except KeyboardInterrupt: + logger.debug("Keyboard requested : killing all process attached to port {}".format(port)) from killSalomeWithPort import killMyPortSSL killMyPortSSL(port) pass diff --git a/bin/runSalomeCommon.py b/bin/runSalomeCommon.py index 354017404..bbe117f7f 100755 --- a/bin/runSalomeCommon.py +++ b/bin/runSalomeCommon.py @@ -322,7 +322,6 @@ class CommonSessionServer(Server): pass if 'language' in self.args: self.SCMD2+=['--language=%s' % self.args['language']] - tempfile.mkstemp() os_handle, iorfakens = tempfile.mkstemp() self.iorfakens = iorfakens os.close(os_handle) diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 3cdc0c0a0..6687da1a4 100755 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -367,7 +367,7 @@ class SalomeContext: sys.argv = ['runSalome'] + args import setenv setenv.main(True, exeName="salome withsession") - + import runSalome runSalome.runSalome() return 0 diff --git a/src/Logger/SALOME_Logger_Server_main.cxx b/src/Logger/SALOME_Logger_Server_main.cxx index b2328f683..a0b60b130 100644 --- a/src/Logger/SALOME_Logger_Server_main.cxx +++ b/src/Logger/SALOME_Logger_Server_main.cxx @@ -32,6 +32,7 @@ #include #include #include +#include "KernelBasis.hxx" #ifndef WIN32 # include @@ -61,7 +62,7 @@ int main(int argc, char **argv) CORBA::Object_var obj; PortableServer::POA_var poa; PortableServer::POAManager_var pman; - + setSSLMode(false); SetArgcArgv(argc, argv); CORBA::ORB_var orb = KERNEL::GetRefToORB() ; diff --git a/src/Logger/SALOME_Trace.py b/src/Logger/SALOME_Trace.py index b9b5058c4..41e730241 100644 --- a/src/Logger/SALOME_Trace.py +++ b/src/Logger/SALOME_Trace.py @@ -37,42 +37,60 @@ if ("SALOME_trace" in os.environ): if (os.environ["SALOME_trace"] == "with_logger"): trace="logger" -class SALOME_Trace : - def __init__(self): - self.m_pInterfaceLogger = None - if trace=="logger": - ok = 0 - steps = 40 - while steps > 0 and ok == 0: +def ReturnLoggerOld(): + m_pInterfaceLogger = None + ok = 0 + steps = 40 + while steps > 0 and ok == 0: + + try: + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + theObj = orb.resolve_initial_references("NameService") + inc = theObj._narrow(CosNaming.NamingContext) + name = [CosNaming.NameComponent("Logger","")] + obj = inc.resolve(name); - try: - orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) - theObj = orb.resolve_initial_references("NameService") - inc = theObj._narrow(CosNaming.NamingContext) - name = [CosNaming.NameComponent("Logger","")] - obj = inc.resolve(name); + m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger) - self.m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger) + if not m_pInterfaceLogger is None: + ok = 1 + except CosNaming.NamingContext.NotFound as e : + if steps == 1: print("Caught exception: Naming Service can't found Logger") + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + if steps == 1: print("Caught CORBA::SystemException CommFailure") + except CORBA.SystemException as e: + if steps == 1: print("Caught CORBA::SystemException.") + except CORBA.Exception as e: + if steps == 1: print("Caught CORBA::Exception.") + except Exception as e: + if steps == 1: print("Caught unknown exception.") - if not self.m_pInterfaceLogger is None: - ok = 1 + time.sleep(0.25) + steps = steps - 1 + return m_pInterfaceLogger + +def ReturnLoggerSSL(): + import KernelLogger + m_pInterfaceLogger = None + try: + m_pInterfaceLogger = KernelLogger.myLogger() + except Exception: + pass + return m_pInterfaceLogger - except CosNaming.NamingContext.NotFound as e : - if steps == 1: print("Caught exception: Naming Service can't found Logger") - except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): - if steps == 1: print("Caught CORBA::SystemException CommFailure") - except CORBA.SystemException as e: - if steps == 1: print("Caught CORBA::SystemException.") - except CORBA.Exception as e: - if steps == 1: print("Caught CORBA::Exception.") - except Exception as e: - if steps == 1: print("Caught unknown exception.") +class SALOME_Trace : + def __init__(self): + self.m_pInterfaceLogger = None + if trace=="logger": + import KernelBasis + if KernelBasis.getSSLMode(): + self.m_pInterfaceLogger = ReturnLoggerSSL() + else: + self.m_pInterfaceLogger = ReturnLoggerOld() - time.sleep(0.25) - steps = steps - 1 def putMessage ( self, LogMsg ) : if (CORBA.is_nil(self.m_pInterfaceLogger)): - print(LogMsg); + print(LogMsg) else: - self.m_pInterfaceLogger.putMessage (LogMsg) + self.m_pInterfaceLogger.putMessage(LogMsg) diff --git a/src/SALOMETraceCollector/CMakeLists.txt b/src/SALOMETraceCollector/CMakeLists.txt index b6bfd678b..d7cdeab3e 100644 --- a/src/SALOMETraceCollector/CMakeLists.txt +++ b/src/SALOMETraceCollector/CMakeLists.txt @@ -27,13 +27,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService + ${CMAKE_CURRENT_SOURCE_DIR}/../Logger ${PROJECT_BINARY_DIR}/idl ) ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${PTHREAD_DEFINITIONS}) ADD_LIBRARY(with_loggerTraceCollector SALOMETraceCollector.cxx TraceCollector_WaitForServerReadiness.cxx) -TARGET_LINK_LIBRARIES(with_loggerTraceCollector SalomeNS ArgvKeeper SALOMELocalTrace OpUtil SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PTHREAD_LIBRARIES}) +TARGET_LINK_LIBRARIES(with_loggerTraceCollector SalomeNS ArgvKeeper SALOMELocalTrace SalomeLoggerServer OpUtil SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PTHREAD_LIBRARIES}) INSTALL(TARGETS with_loggerTraceCollector EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 716cd5985..82fdc3e67 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -209,11 +209,23 @@ SALOMETraceCollector::SALOMETraceCollector() */ // ============================================================================ +#include "KernelBasis.hxx" +#include "SALOME_Logger_Server.hxx" +#include "SALOME_Fake_NamingService.hxx" + +#include + extern "C" { SALOMETRACECOLLECTOR_EXPORT BaseTraceCollector *SingletonInstance(void) { + if(getSSLMode()) + { + SALOME_Logger::Logger_var logger = KERNEL::getLoggerServantSA(); + std::unique_ptr ns(new SALOME_Fake_NamingService); + ns->Register(logger,"/Logger"); + } BaseTraceCollector *instance = SALOMETraceCollector::instance(); return instance; } diff --git a/src/Utils/Test/UtilsTest.cxx b/src/Utils/Test/UtilsTest.cxx index 2f14c1c07..8a3d1dab2 100644 --- a/src/Utils/Test/UtilsTest.cxx +++ b/src/Utils/Test/UtilsTest.cxx @@ -30,6 +30,7 @@ #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" #include "utilities.h" +#include "KernelBasis.hxx" #ifdef WIN32 #define setenv Kernel_Utils::setenv @@ -53,6 +54,7 @@ UtilsTest::_getTraceFileName() void UtilsTest::setUp() { + setSSLMode(false); LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); CPPUNIT_ASSERT(bp1); bp1->deleteInstance(bp1);