From adc122a1685abcbee79d1b07f96db6bf7107175f Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 21 Feb 2022 09:32:48 +0100 Subject: [PATCH] End of Fix foreground into runSalome.py --- bin/killSalomeWithPort.py | 32 ++++++++++++++++++++++++++++++++ bin/runSalome.py | 5 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 59a6c2b93..5375452df 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -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. diff --git a/bin/runSalome.py b/bin/runSalome.py index c190da15c..ff6fff387 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -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 # -- 2.39.2