2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 ## \file killSalome.py
26 # Stop all %SALOME servers from all sessions by killing them
29 import os, sys, re, signal
31 from killSalomeWithPort import killMyPort, getPiDict
35 Kill all SALOME sessions belonging to the user.
37 user = os.getenv('USER')
38 # new-style dot-prefixed pidict file
39 #fpidict = getPiDict('(\d*)',hidden=True)
40 #problem with WIN32 path slashes
41 fpidict = getPiDict('#####',hidden=True)
42 dirpidict = os.path.dirname(fpidict)
43 fpidict = os.path.basename(fpidict)
44 fpidict = fpidict.replace('#####', '(\d*)')
45 fnamere = re.compile("^%s$" % fpidict)
47 for f in os.listdir(dirpidict):
50 killMyPort(mo.group(1))
57 # provide compatibility with old-style pidict file (not dot-prefixed)
58 #fpidict = getPiDict('(\d*)',hidden=False)
59 fpidict = getPiDict('#####',hidden=True)
60 dirpidict = os.path.dirname(fpidict)
61 fpidict = os.path.basename(fpidict)
62 fpidict = fpidict.replace('#####', '(\d*)')
63 fnamere = re.compile("^%s$" % fpidict)
65 for f in os.listdir(dirpidict):
68 killMyPort(mo.group(1))
75 # kill other processes
76 if sys.platform != 'win32':
78 cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
79 prc = commands.getoutput(cmd)
80 for field in prc.split():
82 os.kill(int(field), signal.SIGKILL)
89 if __name__ == "__main__":