Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 import subprocess,os,sys,cmsScimarkStop,time
00008 user=os.environ['USER']
00009
00010 def main():
00011 exitcode=0
00012
00013 cmsScimarkStop.main()
00014
00015
00016 scripts=['cmsPerfSuite.py',
00017 'cmsRelvalreportInput.py',
00018 'cmsRelvalreport.py',
00019 'cmsDriver.py',
00020 'cmsRun',
00021 'cmsScimark2',
00022 'cmsIgProf_Analysis.py',
00023 'igprof-analyse',
00024 'perfreport'
00025 ]
00026
00027
00028 print "Looking for processes by user %s"%user
00029 checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
00030 for line in checkProcesses.stdout:
00031 for executable in scripts:
00032
00033 if executable in line:
00034 print "Found process %s"%line
00035 print "Killing it!"
00036 PID=line.split()[1]
00037 kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
00038 print kill_stdouterr
00039
00040
00041 i=0
00042 while i<100:
00043 exitcode=0
00044 checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
00045 for line in checkProcesses.stdout:
00046 for executable in scripts:
00047 if executable in line:
00048 print "Something funny going on! It seems I could not kill process:\n%s"%line
00049 print "SORRY!"
00050 exitcode=-1
00051 if exitcode>=0:
00052 print "Finally killed all jobs!"
00053 break
00054 i+=1
00055 time.sleep(2)
00056
00057 return exitcode
00058
00059 if __name__ == "__main__":
00060 sys.exit(main())