]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Dfl SSL mode : Fix runSalome.py -l (with logger) agy/29134_3
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 24 Feb 2022 10:39:29 +0000 (11:39 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 24 Feb 2022 10:39:29 +0000 (11:39 +0100)
src/Logger/SALOME_Trace.py

index b9b5058c42be855a649da079e3e3e3a8a2b4258a..41e730241695af49aab2076459e6d867454a0691 100644 (file)
@@ -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)