1 #! /usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2024 CEA, EDF
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 import driver_internal
23 import subprocess as sp
25 import SALOME_Embedded_NamingService_ClientPy
27 from SALOME_PyNode import FileDeleter
35 def handler(signum, frame):
38 ns = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy( NamingService.NamingService.LoadIORInFile( ior_file.filename ) )
40 cm = ns.Resolve(salome.CM_NAME_IN_NS)
41 cm.ShutdownContainersNow()
44 os.kill( proc.pid, signal.SIGKILL )
46 if __name__ == "__main__":
49 signal.signal(signal.SIGINT, handler)
50 signal.signal(signal.SIGTERM, handler)
51 with tempfile.NamedTemporaryFile(prefix="ior_driver_",suffix=".ior") as f:
52 ior_file = FileDeleter( f.name )
53 iorStuff = "{}={}".format( driver_internal.IOREntryInCMD, ior_file.filename)
54 argv = [elt for elt in sys.argv[1:] if elt != ""]
55 cmd = ["python3",driver_internal.__file__] + [ iorStuff ] + argv
56 proc = sp.Popen( cmd )
59 code = proc.returncode
61 raise RuntimeError(f"Subprocess finished with a non zero status ({code}). Command returning non zero status was : {cmd}")