- for file in os.listdir("/tmp"):
- l = string.split(file, "_")
- if len(l) >= 4:
- if file[:len(user)] == user:
- if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict":
- killMyPort(l[len(l)-3])
+ #hostname = getHostName()
+ #shostname = getShortHostName()
+ # new-style dot-prefixed pidict file
+ #fpidict = getPiDict('(\d*)',hidden=True)
+ #problem with WIN32 path slashes
+ fpidict = getPiDict('#####',hidden=True)
+ dirpidict = os.path.dirname(fpidict)
+ fpidict = os.path.basename(fpidict)
+ #if hostname in fpidict:
+ # fpidict = fpidict.replace(hostname, shostname+".*")
+ fpidict = fpidict.replace('#####', '(\d*)')
+ fnamere = re.compile("^%s$" % fpidict)
+ try:
+ for f in os.listdir(dirpidict):
+ mo = fnamere.match(f)
+ try:
+ killMyPort(mo.group(1))
+ except:
+ pass
+ pass
+ pass
+ except:
+ pass
+ # provide compatibility with old-style pidict file (not dot-prefixed)
+ #fpidict = getPiDict('(\d*)',hidden=False)
+ fpidict = getPiDict('#####',hidden=False)
+ dirpidict = os.path.dirname(fpidict)
+ fpidict = os.path.basename(fpidict)
+ #if hostname in fpidict:
+ # fpidict = fpidict.replace(hostname, shostname+".*")
+ fpidict = fpidict.replace('#####', '(\d*)')
+ fnamere = re.compile("^%s$" % fpidict)
+ try:
+ for f in os.listdir(dirpidict):
+ mo = fnamere.match(f)
+ try:
+ killMyPort(mo.group(1))
+ except:
+ pass
+ pass
+ pass
+ except:
+ pass
+ # kill other processes
+ if sys.platform != 'win32':
+ import commands
+ cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
+ prc = commands.getoutput(cmd)
+ for field in prc.split():
+ try:
+ os.kill(int(field), signal.SIGKILL)
+ except:
+ pass
+ pass