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):
"""
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():
# 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)
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()
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)
global process_id
from addToKillList import addToKillList
for pid, cmd in list(process_id.items()):
- addToKillList(pid, cmd, args['port'])
+ addToKillList(pid, cmd)
# -----------------------------------------------------------------------------
# --
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>
+ 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
# -----------------------------------------------------------------------------
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
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)
sys.argv = ['runSalome'] + args
import setenv
setenv.main(True, exeName="salome withsession")
-
+
import runSalome
runSalome.runSalome()
return 0
#include <SALOMEconfig.h>
#include <sys/types.h>
#include <stdlib.h>
+#include "KernelBasis.hxx"
#ifndef WIN32
# include <unistd.h>
CORBA::Object_var obj;
PortableServer::POA_var poa;
PortableServer::POAManager_var pman;
-
+ setSSLMode(false);
SetArgcArgv(argc, argv);
CORBA::ORB_var orb = KERNEL::GetRefToORB() ;
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)
${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")
*/
// ============================================================================
+#include "KernelBasis.hxx"
+#include "SALOME_Logger_Server.hxx"
+#include "SALOME_Fake_NamingService.hxx"
+
+#include <memory>
+
extern "C"
{
SALOMETRACECOLLECTOR_EXPORT
BaseTraceCollector *SingletonInstance(void)
{
+ if(getSSLMode())
+ {
+ SALOME_Logger::Logger_var logger = KERNEL::getLoggerServantSA();
+ std::unique_ptr<SALOME_Fake_NamingService> ns(new SALOME_Fake_NamingService);
+ ns->Register(logger,"/Logger");
+ }
BaseTraceCollector *instance = SALOMETraceCollector::instance();
return instance;
}
#include "Basics_Utils.hxx"
#include "Basics_DirUtils.hxx"
#include "utilities.h"
+#include "KernelBasis.hxx"
#ifdef WIN32
#define setenv Kernel_Utils::setenv
void
UtilsTest::setUp()
{
+ setSSLMode(false);
LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
CPPUNIT_ASSERT(bp1);
bp1->deleteInstance(bp1);