From dcd47e5a70a2fd4127865e1049f3684b2ddbf83c Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 24 Feb 2022 11:39:29 +0100 Subject: [PATCH] Dfl SSL mode : Fix runSalome.py -l (with logger) --- src/Logger/SALOME_Trace.py | 78 +++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 30 deletions(-) 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) -- 2.39.2