]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
End of Fix foreground into runSalome.py
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Feb 2022 08:32:48 +0000 (09:32 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Feb 2022 08:32:48 +0000 (09:32 +0100)
bin/killSalomeWithPort.py
bin/runSalome.py

index 59a6c2b93e5c3292be19191a1d2f20a0b31ca89d..5375452df8317cebcae2b9639e7902b7c21d9042 100755 (executable)
@@ -302,6 +302,38 @@ def __guessPiDictFilename(port):
 
     return None
 
+def killMyPortSSL(*ports):
+    """ Called by runSalome.py after CTRL-C"""
+    for port in ports:
+        # ensure port is an integer
+        with suppress(ValueError):
+            port = int(port)
+
+        with suppress(Exception):
+            # DO NOT REMOVE NEXT LINE: it tests PortManager availability!
+            from PortManager import releasePort
+            # get pidict file
+            filedict = getPiDict(port)
+            if not osp.isfile(filedict): # removed by previous call, see (1) above
+                if verbose():
+                    print("SALOME session on port {} is already stopped".format(port))
+                # remove port from PortManager config file
+                with suppress(ImportError):
+                    if verbose():
+                        print("Removing port from PortManager configuration file")
+                    releasePort(port)
+                return
+        try:
+            # DO NOT REMOVE NEXT LINE: it tests PortManager availability!
+            import PortManager # pragma pylint: disable=unused-import
+            for file_path in glob('{}*'.format(getPiDict(port))):
+                __killMyPort(port, file_path)
+        except ImportError:
+            __killMyPort(port, __guessPiDictFilename(port))
+
+        # clear-up omniOrb config files
+        appliCleanOmniOrbConfig(port)
+
 def killMyPort(*ports):
     """
     Kill SALOME session running on the specified port.
index c190da15cae949918c240926d3c3d693c5621940..ff6fff387e5e6071a7352cfce4341a4bd10c542b 100755 (executable)
@@ -193,6 +193,7 @@ def main(exeName=None):
 
 def foreGround(args, ior_fakens_filename):
     # --
+    import os
     gui_detected = False
     dt = 0.1
     nbtot = 100
@@ -273,8 +274,8 @@ def foreGround(args, ior_fakens_filename):
             pass
         pass
     except KeyboardInterrupt:
-        from killSalomeWithPort import killMyPort
-        killMyPort(port)
+        from killSalomeWithPort import killMyPortSSL
+        killMyPortSSL(port)
         pass
     return
 #