import os,argparse parser=argparse.ArgumentParser(description='Reads a file and plots stuff.') parser.add_argument('--filename',help='name of the svn logfile',default='not') parser.add_argument('--loadroot',help='load rootlogon',action='store_true') parser.add_argument('--mbroot',help='load rootlogon',action='store_true') args = parser.parse_args() if args.loadroot: os.system('. rootlogin 534-03') os.system('rootlogin 534-03') if args.mbroot: os.system('. ~/pandaroot/fairsoft/tools/root/bin/thisroot.sh') import ROOT class writer: def __init__(self,nam): self.name=nam self.times=[] self.dates=[] self.subm=0 self.maxt=(ROOT.TDatime(1995,12,00,00,00,00)).Convert() self.mint=(ROOT.TDatime(2053,12,00,00,00,00)).Convert() T0=ROOT.TDatime(2012,12,12,00,00,00) T1=ROOT.TDatime(2012,12,13,00,00,00) self.daytime=ROOT.TH1D("daytime_"+self.name,"Contribution at Daytime",24,T0.Convert(),T1.Convert()) self.daytime.GetXaxis().SetTimeDisplay(1) self.daytime.GetXaxis().SetTimeFormat("%H:%M") self.daytime.SetStats(0) def add_datetime(self,date,time): date=date.split('-') time=time.split(':') tempt=(ROOT.TDatime(int(date[0]),int(date[1]),int(date[2]),0,0,0)).Convert() tdates=[] ttimes=[] for i in range(3): tdates.append(date[i]) ttimes.append(time[i]) self.dates.append(tdates) self.times.append(ttimes) self.subm+=1 self.time=tempt if tempt>self.maxt: self.maxt=tempt if tempt log') infile=open('log','r') else: infile=open(args.filename,'r') firsttime=9999999999999999 lasttime=0 for line in infile: words=line.split() if len(words)<2: continue if words[0][0]=='r' and words[1]=='|': if users.get(words[2],'none')!='none': users[words[2]].add_datetime(words[4],words[5]) else: users[words[2]]=writer(words[2]) users[words[2]].add_datetime(words[4],words[5]) firsttime=min(users[words[2]].time,firsttime) lasttime=max(users[words[2]].time,lasttime) dy=0.05*len(users) leg=ROOT.TLegend(0.7,0.9-dy,0.9,0.9) leg2=ROOT.TLegend(0.7,0.9-dy,0.9,0.9) leg.SetFillColor(0) leg2.SetFillColor(0) counter=1 for u in users: users[u].maxt=lasttime users[u].mint=firsttime users[u].fill() leg.AddEntry(users[u].daytime,u+': '+str(users[u].subm)) leg2.AddEntry(users[u].meancon,u+': '+str("{0:2.2F}".format(users[u].meancon.GetMean()))) if counter==5: users[u].daytime.SetLineColor(ROOT.kViolet+4) users[u].contr.SetLineColor(ROOT.kViolet+4) users[u].meancon.SetLineColor(ROOT.kViolet+4) else: users[u].daytime.SetLineColor(counter) users[u].contr.SetLineColor(counter) users[u].meancon.SetLineColor(counter) counter+=1 counter=0 c=ROOT.TCanvas("bla","Contributions",1400,800) c.Divide(1,2) c.GetPad(1).Divide(2,1) c.GetPad(2).SetLeftMargin(0.058) c.GetPad(2).SetRightMargin(0.058) max1=0 max2=0 max3=0 for u in users: if users[u].daytime.GetMaximum()>max1: max1=users[u].daytime.GetMaximum() if users[u].meancon.GetMaximum()>max2: max2=users[u].meancon.GetMaximum() if users[u].contr.GetMaximum()>max3: max3=users[u].contr.GetMaximum() for u in users: if counter==0: c.GetPad(1).cd(1) users[u].daytime.GetYaxis().SetRangeUser(0,max1*1.1) users[u].daytime.Draw() c.GetPad(1).cd(2) users[u].meancon.GetYaxis().SetRangeUser(0,max2*1.1) users[u].meancon.Draw() c.cd(2) users[u].contr.GetYaxis().SetRangeUser(0,max3*1.1) users[u].contr.Draw() else: c.GetPad(1).cd(1) users[u].daytime.Draw("same") c.GetPad(1).cd(2) users[u].meancon.Draw("same") c.cd(2) users[u].contr.Draw("same") counter+=1 c.GetPad(1).cd(1) leg.Draw() c.GetPad(1).cd(2) leg2.Draw() c.SaveAs("contributions.pdf") u=raw_input("Press enter to finish")