14 from array
import array
15 from copy
import deepcopy
16 from os
import chdir,getcwd,listdir,makedirs,rmdir
17 from os.path
import exists,join
24 from definitions
import *
25 from utils
import setTDRStyle
38 if msg_level>=_log_level:
39 print "[%s] %s" %(asctime(),message)
51 def __init__(self,sample="",release1="",release2="",run1="",run2="",tier1=0,tier2=0):
62 def __init__(self,name,mother_dir="",meta=CompInfo(),draw_success=
False,do_pngs=
False):
77 Weighted.__init__(self,name)
81 self.rank_histo.SetDirectory(0)
89 '''Walk all subdirs and calculate weight,fails and successes.
90 Moreove propagate the sample and releases names.
110 if comp.status == SKIPED:
115 self.rank_histo.Fill(comp.rank)
117 if comp.status == FAIL:
120 elif comp.status == SUCCESS:
129 subdir.calcStats(make_pie)
130 subdir.meta=self.
meta
131 self.
weight+=subdir.weight
138 self.rank_histo.Add(subdir.rank_histo)
147 subdirdict[subdir.name]=subdir
153 subdirnames.append(subdir.name)
157 """Emit the ajax to build a pie chart using google apis...
159 url =
"https://chart.googleapis.com/chart?"
162 url+=
"&chco=00FF00|FFFF00|FF0000|7A7A7A"
163 url+=
"&chs=%sx%s" %(w,h)
175 fail_comps=sorted(fail_comps,key=
lambda comp:comp.name )
176 if len(fail_comps)>0:
178 for comp
in fail_comps:
179 print indent+
" - %s: %s Test Failed (pval = %s) " %(comp.name,comp.test_name,comp.rank)
181 subdir.print_report(indent+
" ",verbose)
184 print "\n%s - summary of %s tests:" %(self.
name,self.
weight)
191 if self.
weight == 0:
return 0
194 if self.
weight == 0:
return 0
198 if self.
weight == 0:
return 1
202 if self.
weight == 0:
return 0
215 if not exists(full_path)
and len(full_path)>0:
229 valsa=array(
'f',vals)
230 colorsa=array(
'i',colors)
231 can = TCanvas(
"cpie",
"TPie test",100,100);
233 pie = TPie(
"ThePie",self.
name,len(vals),valsa,colorsa);
246 pie.SetAngularOffset(0.);
247 pie.SetLabelsOffset(-.3);
252 print "self.name = %s" %self.
name
253 print "len(vals) = %s (vals=%s)" %(len(vals),vals)
254 print "valsa = %s" %valsa
255 print "colorsa = %s" %colorsa
258 """Eliminate from the tree the directory the expandable ones.
266 subdir.mother_dir=subdir.mother_dir.replace(
"/"+expandable_dir,
"")
267 if subdir.name==expandable_dir:
273 exp_dir=self.
subdirs[exp_index]
274 for subsubdir
in exp_dir.subdirs:
276 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"/"+expandable_dir,
"")
277 while "//" in subsubdir.mother_dir:
278 print subsubdir.mother_dir
279 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"//",
"/")
281 self.subdirs.append(subsubdir)
283 for comp
in exp_dir.comparisons:
284 comp.mother_dir=comp.mother_dir.replace(
"/"+expandable_dir,
"")
285 while "//" in comp.mother_dir:
287 comp.mother_dir=comp.mother_dir.replace(
"/")
289 self.comparisons.append(comp)
296 self.
prune(expandable_dir)
299 subdir.prune(expandable_dir)
303 return "%s seems to be empty. Please check!" %self.
name
306 content+=
" %s\n" % subdir
308 content+=
" %s\n" % comp
312 from multiprocessing
import Process
314 canvas.Print(img_name)
316 tcanvas_print_processes=[]
322 def __init__(self,name,mother_dir,h1,h2,stat_test,draw_success=False,do_pngs=False, skip=False):
328 Weighted.__init__(self,name)
330 stat_test.set_operands(h1,h2)
338 self.
status=stat_test.get_status()
339 self.
rank=stat_test.get_rank()
356 self.
img_name=self.img_name.replace(
"Run summary",
"")
357 self.
img_name=self.img_name.replace(
"/",
"_")
358 self.
img_name=self.img_name.strip(
"_")
367 p = Process(target=print_multi_threaded, args=(canvas,self.
img_name))
369 tcanvas_print_processes.append(p)
370 n_proc=len(tcanvas_print_processes)
373 for iprocess
in xrange(0,n_proc):
374 p=tcanvas_print_processes[iprocess]
376 p_to_remove.append(iprocess)
379 for iprocess
in p_to_remove:
380 tcanvas_print_processes.pop(iprocess-adjustment)
388 canvas=TCanvas(self.
name,self.
name,Comparison.canvas_xsize,Comparison.canvas_ysize)
392 obj1.SetTitle(self.
name)
394 if obj1.GetNbinsY()!=0
and not "2" in obj1.ClassName() :
395 obj1 .SetLineWidth(2)
396 obj2 .SetLineWidth(2)
398 obj1.SetMarkerStyle(8)
399 obj1.SetMarkerSize(.8)
401 obj2.SetMarkerStyle(8)
402 obj2.SetMarkerSize(.8)
404 obj1.SetMarkerColor(kBlue)
405 obj1.SetLineColor(kBlue)
407 obj2.SetMarkerColor(kRed)
408 obj2.SetLineColor(kRed)
412 obj2.Draw(
"HistSames")
436 print "This comparison failed %f" %self.
rank
443 lat_text=
"#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.
test_name,self.
rank)
444 lat=TLatex(.1,.91,lat_text)
460 lat_text1=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
461 lat1=TLatex(.3,.91,lat_text1)
466 lat_text2=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
467 lat2=TLatex(.6,.91,lat_text2)
def get_summary_chart_ajax
static std::string join(char **cmd)
def get_summary_chart_name