From: Anthony Geay Date: Sat, 19 Feb 2022 06:41:02 +0000 (+0100) Subject: Start of management of foreground in SSL context X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ee5de79029d6510452bb756ba5d13680135ab67f;p=modules%2Fkernel.git Start of management of foreground in SSL context --- diff --git a/bin/runSalome.py b/bin/runSalome.py index bd0a5bcaf..e0c800e33 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -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 # diff --git a/bin/runSalomeCommon.py b/bin/runSalomeCommon.py index 1e3295a7e..354017404 100755 --- a/bin/runSalomeCommon.py +++ b/bin/runSalomeCommon.py @@ -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 diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index d0776b5ff..d2be57dfc 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -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): """