2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2015 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, or (at your option) any later version.
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
32 #from salome_utils import getHostName, getShortHostName
36 Kill all SALOME sessions belonging to the user.
38 user = os.getenv('USER')
39 #hostname = getHostName()
40 #shostname = getShortHostName()
41 # new-style dot-prefixed pidict file
42 #fpidict = getPiDict('(\d*)',hidden=True)
43 #problem with WIN32 path slashes
44 fpidict = getPiDict('#####',hidden=True)
45 dirpidict = os.path.dirname(fpidict)
46 fpidict = os.path.basename(fpidict)
47 #if hostname in fpidict:
48 # fpidict = fpidict.replace(hostname, shostname+".*")
49 fpidict = fpidict.replace('#####', '(\d*)')
50 fnamere = re.compile("^%s" % fpidict)
52 for f in os.listdir(dirpidict):
55 killMyPort(mo.group(1))
62 # provide compatibility with old-style pidict file (not dot-prefixed)
63 #fpidict = getPiDict('(\d*)',hidden=False)
64 fpidict = getPiDict('#####',hidden=False)
65 dirpidict = os.path.dirname(fpidict)
66 fpidict = os.path.basename(fpidict)
67 #if hostname in fpidict:
68 # fpidict = fpidict.replace(hostname, shostname+".*")
69 fpidict = fpidict.replace('#####', '(\d*)')
70 fnamere = re.compile("^%s$" % fpidict)
72 for f in os.listdir(dirpidict):
75 killMyPort(mo.group(1))
82 # kill other processes
83 if sys.platform != 'win32':
85 cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
86 prc = commands.getoutput(cmd)
87 for field in prc.split():
89 os.kill(int(field), signal.SIGKILL)
96 if __name__ == "__main__":
98 from salomeContextUtils import setOmniOrbUserPath