import os,sys pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') import argparse parser=argparse.ArgumentParser(description='delete all batch jobs in listfile') parser.add_argument('--listfile',help='the file with the joblist',type=str,default='NONE') parser.add_argument('--pattern',help='delete all files with pattern',type=str,default='NONE') parser.add_argument('--range',help='all job ids in range',type=int,nargs=2,default=[-1,-1]) args=parser.parse_args() if args.listfile!='NONE': for line in open(args.listfile,'read'): print line os.system('qdel '+line) exit() if args.pattern!='NONE': tmpfile=open('batchout_tmp','w') os.system('qstat -n -1 > batchout_tmp') tmpfile.close() for line in open('batchout_tmp','r'): if line.find(args.pattern)!=-1: words=line.split() jobid=words[0].split('.') print jobid[0] os.system('qdel '+jobid[0]) exit() if args.range[0]!=-1: for i in range(args.range[0],args.range[1]): print i os.system('qdel '+str(i))