]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Start of management of foreground in SSL context
authorAnthony Geay <anthony.geay@edf.fr>
Sat, 19 Feb 2022 06:41:02 +0000 (07:41 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Sat, 19 Feb 2022 06:41:02 +0000 (07:41 +0100)
bin/runSalome.py
bin/runSalomeCommon.py
src/KERNEL_PY/__init__.py

index bd0a5bcaf78337638de4a13ee3cf354f4869044b..e0c800e33d2b70bfeeee63236d9bc2e1da08e9b6 100755 (executable)
@@ -70,6 +70,8 @@ def startSalome(args, modules_list, modules_root_dir):
 
     logger.debug("startSalome : {} ".format(args))
 
+    ior_fakens_filename = None
+
     # Launch  Session Server (to show splash ASAP)
     #
 
@@ -77,6 +79,7 @@ def startSalome(args, modules_list, modules_root_dir):
         mySessionServ = runSalomeNoServer.NoSessionServer(args,args['modules'],modules_root_dir)
         mySessionServ.setpath(modules_list,modules_root_dir)
         mySessionServ.run()
+        ior_fakens_filename = mySessionServ.iorfakens
     
     end_time = os.times()
 
@@ -96,14 +99,13 @@ def startSalome(args, modules_list, modules_root_dir):
     except Exception:
         import traceback
         traceback.print_exc()
-        print("-------------------------------------------------------------")
-        print("-- to get an external python interpreter:runSalome --interp=1")
-        print("-------------------------------------------------------------")
+        logger.error("-------------------------------------------------------------")
+        logger.error("-- to get an external python interpreter:runSalome --interp=1")
+        logger.error("-------------------------------------------------------------")
 
     logger.debug("additional external python interpreters: {}".format(nbaddi))
     if nbaddi:
         for i in range(nbaddi):
-            print("i=",i)
             anInterp=InterpServer(args)
             anInterp.run()
 
@@ -115,7 +117,7 @@ def startSalome(args, modules_list, modules_root_dir):
         except ImportError:
             pass
 
-    return
+    return ior_fakens_filename
 
 # -----------------------------------------------------------------------------
 
@@ -126,15 +128,13 @@ def useSalome(args, modules_list, modules_root_dir):
     show registered objects in Naming Service.
     """
     global process_id
-
+    ior_fakens_filename = None
     try:
-        startSalome(args, modules_list, modules_root_dir)
+        ior_fakens_filename = startSalome(args, modules_list, modules_root_dir)
     except Exception:
         import traceback
         traceback.print_exc()
-        print()
-        print()
-        print("--- Error during Salome launch ---")
+        logger.error("--- Error during Salome launch ---")
 
     # print(process_id)
 
@@ -160,7 +160,7 @@ def useSalome(args, modules_list, modules_root_dir):
     the processes resulting from the previous execution.
     """%filedict)
 
-    return
+    return ior_fakens_filename
 
 def execScript(script_path):
     print('executing', script_path)
@@ -186,16 +186,26 @@ def main(exeName=None):
     kill_salome(args)
     # --
     setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
-    useSalome(args, modules_list, modules_root_dir)
-    return args
+    ior_fakens_filename = useSalome(args, modules_list, modules_root_dir)
+    return args, ior_fakens_filename
 
 # -----------------------------------------------------------------------------
 
-def foreGround(args):
+def foreGround(args, ior_fakens_filename):
     # --
-    if "session_object" not in args:
+    if ior_fakens_filename is None:
+        return
+    if not os.path.exists(ior_fakens_filename):
         return
-    session = args["session_object"]
+    import CORBA
+    import Engines
+    orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+    ior_fakens = None
+    try:
+        ior_fakens = orb.string_to_object(open(ior_fakens_filename).read())
+    except Exception:
+        pass
+    session = orb.string_to_object(ior_fakens.Resolve("/Kernel/Session").decode())
     # --
     # Wait until gui is arrived
     # tmax = nbtot * dt
@@ -255,7 +265,7 @@ def foreGround(args):
 #
 
 def runSalome():
-    args = main()
+    args, ior_fakens_filename = main()
     # --
     test = args['gui'] and args['session_gui']
     test = test or args['wake_up_session']
@@ -279,7 +289,7 @@ def runSalome():
     if test:
         from time import sleep
         sleep(3.0)
-        foreGround(args)
+        foreGround(args, ior_fakens_filename)
         pass
     pass
 #
index 1e3295a7e77166142f0a52fad9b7aa7cb1550984..354017404be16e9cf52751a3dcb3d4ff699482c8 100755 (executable)
@@ -242,6 +242,7 @@ class LoggerServer(Server):
 
 # ---
 import abc
+import tempfile
 class CommonSessionServer(Server):
     def __init__(self,args,modules_list,modules_root_dir):
         self.args = args.copy()
@@ -321,6 +322,11 @@ 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)
+        self.SCMD2+=["--iorfakens={}".format(iorfakens)]
         pass
 
     @abc.abstractmethod
index d0776b5ff872430a5b30ea38d89b14a5eaa99405..d2be57dfc30154a84127bf78a2d12c67f7a4737a 100644 (file)
@@ -173,11 +173,14 @@ def withServers():
     import KernelBasis
     KernelBasis.setSSLMode(False)
 
-def salome_init(path=None, embedded=False):
+def salome_init(path=None, embedded=False, iorfakensfile=None):
+    """
+    :param iorfakensfile: filename inside which IOR of fake NS will be written
+    """
     import KernelBasis
     if KernelBasis.getSSLMode():
         if KernelBasis.getIOROfEmbeddedNS() == "":
-            salome_init_without_session(path, embedded)
+            salome_init_without_session(path, embedded, iorfakensfile)
         else:
             salome_init_without_session_attached(path, embedded)
     else:
@@ -220,7 +223,7 @@ def salome_init_without_session_common(path=None, embedded=False):
     from NamingService import NamingService
     naming_service = NamingService()
 
-def salome_init_without_session(path=None, embedded=False):
+def salome_init_without_session(path=None, embedded=False, iorfakensfile=None):
     salome_init_without_session_common(path,embedded)
     global lcc,cm,dsm,esm
     import KernelLauncher
@@ -244,6 +247,11 @@ def salome_init_without_session(path=None, embedded=False):
     #
     import KernelLogger
     naming_service.Register(KernelLogger.myLogger(),"/Logger")
+    #
+    from NamingService import NamingService
+    if iorfakensfile is not None:
+        with open(iorfakensfile,"w") as iorfakensf:
+            iorfakensf.write(NamingService.IOROfNS())
     
 def salome_init_without_session_attached(path=None, embedded=False):
     """