Back to index

salome-kernel  6.5.0
Functions
killSalome Namespace Reference

Functions

def killAllPorts

Function Documentation

Kill all SALOME sessions belonging to the user.

Definition at line 34 of file killSalome.py.

00034 
00035 def killAllPorts():
00036     """
00037     Kill all SALOME sessions belonging to the user.
00038     """
00039     user = os.getenv('USER')
00040     #hostname  = getHostName()
00041     #shostname = getShortHostName()
00042     # new-style dot-prefixed pidict file
00043     #fpidict   = getPiDict('(\d*)',hidden=True)
00044     #problem with WIN32 path slashes
00045     fpidict   = getPiDict('#####',hidden=True)
00046     dirpidict = os.path.dirname(fpidict)
00047     fpidict   = os.path.basename(fpidict)
00048     #if hostname in fpidict:
00049     #    fpidict = fpidict.replace(hostname, shostname+".*")
00050     fpidict   = fpidict.replace('#####', '(\d*)')
00051     fnamere   = re.compile("^%s$" % fpidict)
00052     try:
00053         for f in os.listdir(dirpidict):
00054             mo = fnamere.match(f)
00055             try:
00056                 killMyPort(mo.group(1))
00057             except:
00058                 pass
00059             pass
00060         pass
00061     except:
00062         pass
00063     # provide compatibility with old-style pidict file (not dot-prefixed)
00064     #fpidict   = getPiDict('(\d*)',hidden=False)
00065     fpidict   = getPiDict('#####',hidden=False)
00066     dirpidict = os.path.dirname(fpidict)
00067     fpidict   = os.path.basename(fpidict)
00068     #if hostname in fpidict:
00069     #    fpidict = fpidict.replace(hostname, shostname+".*")
00070     fpidict = fpidict.replace('#####', '(\d*)')
00071     fnamere   = re.compile("^%s$" % fpidict)
00072     try:
00073         for f in os.listdir(dirpidict):
00074             mo = fnamere.match(f)
00075             try:
00076                 killMyPort(mo.group(1))
00077             except:
00078                 pass
00079             pass
00080         pass
00081     except:
00082         pass
00083     # kill other processes
00084     if sys.platform != 'win32':
00085         import commands
00086         cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
00087         prc = commands.getoutput(cmd)
00088         for field in prc.split():
00089             try:
00090                 os.kill(int(field), signal.SIGKILL)
00091             except:
00092                 pass
00093             pass
00094         pass
00095     pass

Here is the call graph for this function:

Here is the caller graph for this function: