2 import os, sys, pickle, signal, commands
4 def getPiDict(port,appname='salome',full=True):
5 from Utils_Identity import getShortHostName
7 if os.getenv("HOSTNAME") == None:
8 if os.getenv("HOST") == None:
9 os.environ["HOSTNAME"]=getShortHostName()
11 os.environ["HOSTNAME"]=os.getenv("HOST")
14 filedict.append( os.getenv('USER') ) # user name
15 filedict.append( os.getenv('HOSTNAME') ) # host name
16 filedict.append( str(port) ) # port number
17 filedict.append( appname.upper() ) # application name
18 filedict.append( 'pidict' ) # constant part
20 filedict = '_'.join(filedict)
22 filedict = os.getenv("HOME") + '/' + filedict
25 ########## kills all salome processes with the given port ##########
27 filedict=getPiDict(port)
30 fpid=open(filedict, 'r')
33 print "le fichier %s des process SALOME n'est pas accessible"% filedict
37 a = os.system("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid >& /dev/null")
39 process_ids=pickle.load(fpid)
41 for process_id in process_ids:
43 for pid, cmd in process_id.items():
44 print "stop process %s : %s"% (pid, cmd[0])
46 os.kill(int(pid),signal.SIGKILL)
48 print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
54 pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
56 while pid != "" and len(a.split(" ")) < 2:
57 a = commands.getoutput("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid")
58 pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
62 if __name__ == "__main__":
63 for port in sys.argv[1:]: