2 import os, sys, pickle, signal, commands
4 def getPiDict(port,appname='salome',full=True):
6 filedict.append( os.getenv('USER') ) # user name
7 filedict.append( os.getenv('HOSTNAME') ) # host name
8 filedict.append( str(port) ) # port number
9 filedict.append( appname.upper() ) # application name
10 filedict.append( 'pidict' ) # constant part
12 filedict = '_'.join(filedict)
14 filedict = os.getenv("HOME") + '/' + filedict
17 ########## kills all salome processes with the given port ##########
19 filedict=getPiDict(port)
22 fpid=open(filedict, 'r')
25 print "le fichier %s des process SALOME n'est pas accessible"% filedict
29 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")
31 process_ids=pickle.load(fpid)
33 for process_id in process_ids:
35 for pid, cmd in process_id.items():
36 print "stop process %s : %s"% (pid, cmd[0])
38 os.kill(int(pid),signal.SIGKILL)
40 print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
46 pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
48 while pid != "" and len(a.split(" ")) < 2:
49 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")
50 pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
54 if __name__ == "__main__":
55 for port in sys.argv[1:]: