import sys,os,math,time,random,string #pandapath=os.environ.get('PANDAPATH') pandapath='/home/walbrecht/fopiroot/fopiroot_dev/' user=os.environ.get('USER') if len(user)>8: user=user[0:7] sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') import argparse def id_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) def checkBatch(getnum=False): if os.path.isfile('stopDevmap'): exit() tmpname='/tmp/batch_tmp_'+id_generator() if args.e18: os.system('qstat > '+tmpname) else: os.system('squeue -o "%.18i %.9P %.8j %.8u %.2t %.10M %.6D %R %p" > '+tmpname) statfile=open(tmpname,'r') njobs=0 nrjobs=0 nqjobs=0 ntjobs=0 running='R' queued='PD' if args.e18: running='r' queued='qw' for line in statfile: if line.find(user)==-1: ntjobs+=1 continue ntjobs+=1 words=line.split() # print words if words[4]==running: nrjobs+=1 if words[4]==queued: nqjobs+=1 njobs+=1 statfile.close() os.system('rm '+tmpname) print 'there are',ntjobs-3,'jobs on the batchfarm' print njobs,'are my jobs' print nrjobs,'jobs are running' print nqjobs,'jobs are in the queue' print args.ofile print '' if njobs=args.maxjobs: print 'jobs:',jobcounter check=-1 while check==-1: timer=0 while timer0: r=int(word.split(":")[1]) # print "r=",r,"zbins=",zBin sub(r,zBin) continue zBin.append(int(word)) exit() if args.specfile!="": inf=open(args.specfile,"r") zbins=[] for line in inf: words=line.split() if words[0]=="r-Bin:": r=int(words[1]) if words[2]=='z-Bin:': zbins=words[3].split(",") if words[2]=='complete': args.specZ='-1' sub(r,[-1]) continue if words[2]=='is': sub(r,[-1]) continue counter=0 args.specZ="" for zbin in zbins: if counter==0: args.specZ+=zbin else: args.specZ+=","+zbin counter+=1 if counter==args.zStep: sub(r,[-1]) args.specZ="" counter=0 if args.specZ!="": sub(r,[-1]) print 'all done, used specfile:',args.specfile exit() if args.rRange[0]!=-1: args.rBin=[] for i in range(args.rRange[0],args.rRange[1]+1): args.rBin.append(i) for rb in args.rBin: print 'submitting',rb,args.zBin sub(rb,args.zBin)