CMS 3D CMS Logo

Functions | Variables

directories2html Namespace Reference

Functions

def build_gauge
def build_obj
def build_obj_addr
def directory2html
def encode_obj_url
def fairy_url
def fairy_url_single
def get_aggr_pairs_info
def get_comparisons
def get_dir_stats
def get_page_footer
def get_page_header
def get_pie_tooltip
def get_rank_section
def get_subdirs_section
def get_summary_section
def get_title_section
def make_barchart_summary
def make_categories_summary
def make_summary_table
def make_twiki_table
def plot_size

Variables

 theargv = sys.argv

Function Documentation

def directories2html::build_gauge (   total_success_rate,
  minrate = .80,
  small = False,
  escaped = False 
)

Definition at line 437 of file directories2html.py.

00438                                                                          :
00439   total_success_rate_scaled=(total_success_rate-minrate)
00440   total_success_rate_scaled_repr=total_success_rate_scaled/(1-minrate)
00441   if total_success_rate_scaled_repr<0:
00442     total_success_rate_scaled_repr=0
00443   size_s="200x100"
00444   if small:
00445     size_s="40x30"
00446   #print "Total success rate %2.2f and scaled %2.2f "%(total_success_rate,total_success_rate_scaled)
00447   gauge_link ="https://chart.googleapis.com/chart?chs=%s&cht=gom"%size_s
00448   gauge_link+="&chd=t:%2.1f"%(total_success_rate_scaled_repr*100.)
00449   if not small:
00450     gauge_link+="&chxt=x,y&chxl=0:|%2.1f%%|1:|%i%%|%i%%|100%%"%(total_success_rate*100,minrate*100.,(1+minrate)*50)
00451     gauge_link+="&chma=10,10,10,0"
00452   img_tag= '<img src="%s">'%gauge_link
00453   if escaped:
00454     img_tag=cgi.escape(img_tag)    
00455   return img_tag
00456 
00457 #-------------------------------------------------------------------------------

def directories2html::build_obj (   run,
  sample,
  version,
  plot_path,
  tier 
)

Definition at line 55 of file directories2html.py.

00056                                                 :
00057   obj_url="obj=%s;" %build_obj_addr(run,sample,version,plot_path,tier)
00058   return encode_obj_url(obj_url)

def directories2html::build_obj_addr (   run,
  sample,
  version,
  plot_path,
  tier 
)

Definition at line 45 of file directories2html.py.

00046                                                      :
00047   slash="/"
00048   obj_url="archive/%s/%s/%s/%s/" %(run,sample,version,tier)
00049   obj_url+=plot_path
00050   while obj_url.endswith(slash):
00051     obj_url=obj_url[:-1]  
00052   while slash*2 in obj_url:
00053     obj_url=obj_url.replace(slash*2,slash)
00054   return obj_url
  
def directories2html::directory2html (   directory,
  depth = 0 
)
Converts a directory tree into html pages, very nice ones.

Definition at line 388 of file directories2html.py.

00389                                       :
00390   """Converts a directory tree into html pages, very nice ones.
00391   """
00392   #print "d2html: depth", str(depth)," dir ",directory.name
00393   depth+=1
00394   #old_cwd=getcwd()
00395   #if not exists(directory.name) and len(directory.name)>0:
00396     #makedirs(directory.name)
00397   
00398   #if len(directory.name)>0:
00399     #chdir(directory.name)
00400   
00401   for subdir in directory.subdirs:
00402     directory2html(subdir,depth)
00403   
00404   page_html=get_page_header(directory)+\
00405             get_title_section(directory,depth)+\
00406             get_summary_section(directory)+\
00407             get_subdirs_section(directory)
00408 
00409   for do_cat,cat in ((directory.n_comp_fails >0,FAIL ),
00410                      (directory.n_comp_nulls >0,NULL ),
00411                      (directory.n_comp_successes >0 and directory.draw_success,SUCCESS )):
00412     if do_cat:      
00413       page_html+=get_comparisons(cat,directory)
00414 
00415   # Distribution of ranks
00416 
00417   if depth==1:
00418     page_html+=get_rank_section(directory)
00419 
00420 
00421   page_html+=get_page_footer()
00422 
00423   page_name=directory.name
00424 
00425   if len(page_name)==0:
00426     page_name="RelMonSummary"
00427   ofilename="%s_%s.html" %(directory.mother_dir.replace("/","_"),page_name)
00428   ofilename=ofilename.strip("_")
00429   #print "Writing on %s" %ofilename
00430   ofile=open(ofilename,"w")
00431   ofile.write(page_html)
00432   ofile.close()
00433 
00434   #chdir(old_cwd)
00435 
00436 #-------------------------------------------------------------------------------

def directories2html::encode_obj_url (   url)

Definition at line 37 of file directories2html.py.

00038                        :
00039   for old,new in url_encode_dict.items():
00040     url=url.replace(old,new)
00041   return url

def directories2html::fairy_url (   run,
  sample,
  version1,
  version2,
  plot_path,
  tier1,
  tier2,
  draw_opts = "",
  h = 250,
  w = 200 
)

Definition at line 59 of file directories2html.py.

00060                                                                                           :
00061   fairy_url = "%s/%s/plotfairy/overlay?" %(server,base_url)
00062   fairy_url+= build_obj(run,sample,version1,plot_path,tier1)
00063   fairy_url+= build_obj(run,sample,version2,plot_path,tier2)
00064   if len(draw_opts)>0:
00065     fairy_url+="drawopts=%s;" %draw_opts
00066   fairy_url+= plot_size(h,w)
00067   return fairy_url

def directories2html::fairy_url_single (   run,
  sample,
  version,
  plot_path,
  tier,
  draw_opts = "",
  h = 250,
  w = 200 
)

Definition at line 68 of file directories2html.py.

00069                                                                                 :
00070   fairy_url = "%s/%s/plotfairy/" %(server,base_url)
00071   fairy_url+=build_obj_addr(run,sample,version,plot_path,tier)
00072   fairy_url+= "?%s"%plot_size(h,w)  
00073   if len(draw_opts)>0:
00074     fairy_url+="drawopts=%s;" %draw_opts  
00075   return fairy_url
00076  
00077 #-------------------------------------------------------------------------------
style_location="https://cms-service-reldqm.web.cern.ch/cms-service-reldqm/"
def directories2html::get_aggr_pairs_info (   dir_dict,
  the_aggr_pairs = [] 
)

Definition at line 458 of file directories2html.py.

00459                                                    :
00460   # Let's make a summary for an overview in categories act on the global dir
00461   aggr_pairs_info=[]#(name,{directories names:{nsucc: nsucc,weight:weight}},weight,success_rate)
00462 
00463   list_of_names=[]
00464   if the_aggr_pairs==[]:
00465     for samplename,sampledir in dir_dict.items():
00466       for subsysdirname in sorted(sampledir.get_subdirs_dict().keys()):
00467         if not subsysdirname in list_of_names:
00468           list_of_names.append(subsysdirname)
00469           the_aggr_pairs.append((subsysdirname,[subsysdirname]))  
00470           
00471   #print the_aggr_pairs
00472   for cat_name, subdir_list in the_aggr_pairs:
00473     total_successes=0.
00474     total_directory_successes=0
00475     total_weight=0.    
00476     present_subdirs={}
00477     total_ndirs=0
00478     # Loop on samples
00479     for dirname, sampledir in dir_dict.items():
00480       # Loop on directories
00481       for subdirname,subdir in sampledir.get_subdirs_dict().items():        
00482         if subdirname in subdir_list:          
00483           nsucc=subdir.n_successes
00484           total_successes+=nsucc
00485           weight=subdir.weight
00486           total_weight+=weight
00487           total_ndirs+=1
00488           
00489           total_directory_successes+= float(nsucc)/weight
00490           if present_subdirs.has_key(subdirname):
00491             this_dir_dict=present_subdirs[subdirname]
00492             this_dir_dict["nsucc"]+=nsucc
00493             this_dir_dict["weight"]+=weight
00494           else:
00495             present_subdirs[subdirname]={"nsucc":nsucc,"weight":weight}
00496         # Make it usable also for subdirectories
00497         for subsubdirname,subsubdir in subdir.get_subdirs_dict().items():          
00498           for pathname in filter(lambda name:"/" in name,subdir_list):           
00499             selected_subdirname,selected_subsubdirname = pathname.split("/")
00500             if selected_subdirname == subdirname and selected_subsubdirname==subsubdirname:
00501               #print "Studying directory ",subsubdirname," in directory ",subdirname
00502               nsucc=subsubdir.n_successes
00503               total_successes+=nsucc
00504               weight=subsubdir.weight
00505               total_weight+=weight
00506               total_ndirs+=1              
00507               total_directory_successes+= float(nsucc)/weight
00508               
00509               if present_subdirs.has_key(subsubdirname):
00510                 this_dir_dict=present_subdirs[subsubdirname]
00511                 this_dir_dict["nsucc"]+=nsucc
00512                 this_dir_dict["weight"]+=weight
00513               else:
00514                 present_subdirs[subsubdirname]={"nsucc":nsucc,"weight":weight}      
00515 
00516     if total_ndirs == 0:
00517       print "No directory of the category %s is present in the samples: skipping." %cat_name
00518       continue
00519     
00520     average_success_rate=total_directory_successes/(total_ndirs)
00521     aggr_pairs_info.append((cat_name,present_subdirs,total_weight,average_success_rate))
00522     
00523   return aggr_pairs_info
00524 
00525 #-------------------------------------------------------------------------------

def directories2html::get_comparisons (   category,
  directory 
)
Prepare the comparisons between histograms and organise them in the page.
Moreover create separate pages with the overlay and the single plots.

Definition at line 256 of file directories2html.py.

00257                                        :
00258   """Prepare the comparisons between histograms and organise them in the page.
00259   Moreover create separate pages with the overlay and the single plots.
00260   """
00261   counter=1
00262   tot_counter=1
00263   
00264   # get the right ones
00265   comparisons= filter (lambda comp: comp.status == cat_states[category] , directory.comparisons) 
00266   
00267   n_comparisons=len(comparisons)    
00268 
00269   is_reverse=True
00270   if category == FAIL:
00271     is_reverse=False  
00272   comparisons=sorted(comparisons, key=lambda comp:comp.rank, reverse=is_reverse)
00273   
00274   dir_abs_path="%s/%s/" %(directory.mother_dir,directory.name)
00275   html_comparisons=""
00276   for comparison in comparisons:
00277     plot_name=comparison.img_name
00278     if "https://" not in plot_name:
00279       plot_name= basename(comparison.img_name)
00280     class_type="colborder"    
00281     if counter==3 or tot_counter==n_comparisons:
00282       class_type=" colborder last"
00283     comp_abs_path="%s/%s" %(dir_abs_path,comparison.name)
00284 
00285 
00286     if directory.do_pngs:
00287       png_link=comparison.img_name
00288       html_comparisons+='<div class="span-6 %s"><p>%s</p>' %(class_type,comparison.name)+\
00289                       '<p class="alt">%s: %.2E</p>' %(comparison.test_name,comparison.rank)+\
00290                       '<a href="%s"><img src="%s" width="250" height="200" class="top center %s"></a></div>'%(png_link,png_link,cat_classes[category])
00291     else:
00292       big_fairy=fairy_url(directory.meta.run1,
00293                         directory.meta.sample,
00294                         directory.meta.release1,
00295                         directory.meta.release2,
00296                         comp_abs_path,
00297                         directory.meta.tier1,
00298                         directory.meta.tier2,
00299                         "",600,600)
00300       small_fairy=fairy_url(directory.meta.run1,
00301                         directory.meta.sample,
00302                         directory.meta.release1,
00303                         directory.meta.release2,
00304                         comp_abs_path,
00305                         directory.meta.tier1,
00306                         directory.meta.tier2)    
00307 
00308       single_fairy1=fairy_url_single(directory.meta.run1,
00309                                    directory.meta.sample,
00310                                    directory.meta.release1,
00311                                    comp_abs_path,
00312                                    directory.meta.tier1,
00313                                    "",500,500)
00314       single_fairy2=fairy_url_single(directory.meta.run2,
00315                                    directory.meta.sample,
00316                                    directory.meta.release2,
00317                                    comp_abs_path,
00318                                    directory.meta.tier2,
00319                                    "",500,500)
00320 
00321       html_comparisons+='<div class="span-6 %s"><p>%s</p>' %(class_type,comparison.name)+\
00322                       '<p class="alt">%s: %.2E</p>' %(comparison.test_name,comparison.rank)+\
00323                       '<div><a class="black_link" href="%s">%s</a></div>'%(single_fairy1,directory.meta.release1)+\
00324                       '<div><a href="%s">%s</a></div>'%(single_fairy2,directory.meta.release2)+\
00325                       '<a href="%s"><img src="%s" class="top center %s"></a></div>'%(big_fairy,small_fairy,cat_classes[category])
00326 
00327     if counter==3:                    
00328       html_comparisons+="<hr>"
00329       counter=0
00330     counter+=1
00331     tot_counter+=1
00332 
00333   if len(html_comparisons)!=0:
00334     html='<div class="span-20"><h2 class="alt">%s Comparisons</h2></div>' %cat_names[category]
00335     html+=html_comparisons
00336     html+='<hr>'
00337     return html
00338   return ""
00339 
00340 #-------------------------------------------------------------------------------

def directories2html::get_dir_stats (   directory)

Definition at line 150 of file directories2html.py.

00151                             :
00152   html='<p><span class="caps alt">%s comparisons:</span></p>'%directory.weight
00153   html+='<ul>'
00154   if directory.n_successes>0:
00155     html+='<li><span class="caps">Success: %.1f%% (%s)</span></li>'%(directory.get_success_rate(),directory.n_successes)
00156   if directory.n_nulls>0:
00157     html+='<li><span class="caps">Null: %.1f%% (%s)</span></li>'%(directory.get_null_rate(),directory.n_nulls)
00158   if directory.n_fails>0:
00159     html+='<li><span class="caps">Fail: %.1f%% (%s)</span></li>'%(directory.get_fail_rate(),directory.n_fails)
00160   html+='</ul>'
00161   return html
00162 
00163 #-------------------------------------------------------------------------------

def directories2html::get_page_footer ( )

Definition at line 113 of file directories2html.py.

00114                      :
00115     return '</div></body></html>'
00116 
00117 #-------------------------------------------------------------------------------

def directories2html::get_page_header (   directory = None,
  additional_header = "" 
)

Definition at line 78 of file directories2html.py.

00079                                                         :
00080   javascripts=''
00081   style=''
00082   if directory!=None and len(directory.comparisons)>0:
00083     meta=directory.meta
00084     style='img.fail {border:1px solid #ff0000;}\n'+\
00085           'img.succes {border:1px solid #00ff00;}\n'+\
00086           'img.null {border:1px solid #ffff00;}\n'+\
00087           'a.black_link:link {color: #333333}\n'+\
00088           'a.black_link:hover {color: #737373}\n'+\
00089           'a.black_link:visited {color: #333333}\n'+\
00090           'a.black_link:active {color: #333333}\n'
00091   javascripts=""
00092   
00093   
00094   html='<html>'+\
00095        '<head>'+\
00096        '<title>RelMon Summary</title>'+\
00097        '<link rel="stylesheet" href="%s/style/blueprint/screen.css" type="text/css" media="screen, projection">'%style_location+\
00098        '<link rel="stylesheet" href="%s/style/blueprint/print.css" type="text/css" media="print">'%style_location+\
00099        '<link rel="stylesheet" href="%s/style/blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">'%style_location+\
00100        '<style type="text/css">'+\
00101        '.rotation {display: block;-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg); }'+\
00102        '%s'%style+\
00103        '</style>'+\
00104        '%s'%javascripts+\
00105        '%s'%additional_header+\
00106        '</head>'+\
00107        '<body>'+\
00108        '<div class="container">'
00109   
00110   return html
00111   
00112 #-------------------------------------------------------------------------------

def directories2html::get_pie_tooltip (   directory)

Definition at line 601 of file directories2html.py.

00602                               :
00603   tooltip="%s\nS:%2.1f%% N:%2.1f%% F:%2.1f%%" %(directory.name,directory.get_success_rate(),directory.get_null_rate(),directory.get_fail_rate())
00604   return tooltip
00605 
00606 #-------------------------------------------------------------------------------

def directories2html::get_rank_section (   directory)

Definition at line 341 of file directories2html.py.

00342                                :
00343 # do Rank histo png
00344     imgname="RankSummary.png"
00345     gStyle.SetPadTickY(0)
00346     c=TCanvas("ranks","ranks",500,400)
00347     #gStyle.SetOptStat(0)
00348     c.cd()
00349 
00350     h=directory.rank_histo
00351     rank_histof=TH1F(h.GetName(),"",h.GetNbinsX(),h.GetXaxis().GetXmin(),h.GetXaxis().GetXmax())
00352     rank_histof.SetLineWidth(2)
00353     for i in xrange(0,h.GetNbinsX()+1):
00354       rank_histof.SetBinContent(i,h.GetBinContent(i))
00355     h.SetTitle("Ranks Summary;Rank;Frequency")
00356     h.Draw("Hist")
00357     c.Update()
00358     rank_histof.ComputeIntegral()
00359     integral = rank_histof.GetIntegral()
00360     rank_histof.SetContent(integral)
00361 
00362     rightmax = 1.1*rank_histof.GetMaximum()
00363     scale = gPad.GetUymax()/rightmax
00364     rank_histof.SetLineColor(kRed)
00365     rank_histof.Scale(scale)
00366     rank_histof.Draw("same")
00367 
00368     #draw an axis on the right side
00369     axis = TGaxis(gPad.GetUxmax(),gPad.GetUymin(),gPad.GetUxmax(), gPad.GetUymax(),0,rightmax,510,"+L")
00370     axis.SetTitle("Cumulative")
00371     axis.SetTitleColor(kRed)
00372     axis.SetLineColor(kRed)
00373     axis.SetLabelColor(kRed)
00374     axis.Draw()
00375 
00376     rank_histof.Draw("Same");
00377     
00378 
00379     c.Print(imgname)
00380 
00381     page_html='<div class="span-20"><h2 class="alt"><a name="rank_summary">Ranks Summary</a></h2>'
00382     page_html+='<div class="span-19"><img src="%s"></div>' %imgname
00383     page_html+='</div> <a href="#top">Top...</a><hr>'
00384 
00385     return page_html
00386     
00387 #-------------------------------------------------------------------------------

def directories2html::get_subdirs_section (   directory)

Definition at line 164 of file directories2html.py.

00164                                   : 
00165   if len(directory.subdirs)==0:
00166     return ""
00167   html= '<div class="span-20 colborder">'
00168   html+='<h2 class="alt">Sub-Directories</h2>'
00169   # sort subdirs according to the number of fails and number of nulls and then alphabveticaly
00170   # so reverse :)
00171   sorted_subdirs= sorted(directory.subdirs, key= lambda subdir: subdir.name)
00172   sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_nulls, reverse=True)
00173   sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_fails, reverse=True)
00174   for subdir in sorted_subdirs:
00175     name=subdir.name
00176     link="%s_%s_%s.html" %(directory.mother_dir.replace("/","_"),directory.name.replace("/","_"),name)
00177     link=link.strip("_")
00178     html+='<div class="span-4 prepend-2 colborder">'
00179     html+='<h3>%s</h3>'%name
00180     html+='</div>'
00181     
00182     html+='<div class="span-7">'
00183     html+=get_dir_stats(subdir)
00184     html+='</div>'
00185     
00186     html+='<div class="span-6 last">'
00187     html+='<a href="%s"><img src="%s" class="top right"></a>'%(link,subdir.get_summary_chart_ajax(150,100))
00188     html+='</div>'
00189     
00190     html+='<hr>'
00191   return html+'</div>'
00192 
00193  
00194 #-------------------------------------------------------------------------------
00195 
def directories2html::get_summary_section (   directory,
  matrix_page = True 
)

Definition at line 196 of file directories2html.py.

00197                                                    :
00198   
00199   # Hack find the first comparison and fill test and threshold
00200   # shall this be put in meta?
00201   test_name=""
00202   test_threshold=0
00203   for comparison in directory.comparisons:
00204       test_name=comparison.test_name
00205       test_threshold=comparison.test_thr
00206       break
00207   if len(test_name)==0:
00208     for subdir in directory.subdirs:  
00209       for comparison in subdir.comparisons:
00210         test_name=comparison.test_name
00211         test_threshold=comparison.test_thr
00212         break
00213       if len(test_name)!=0:break      
00214       if len(test_name)==0:  
00215         for subsubdir in subdir.subdirs:          
00216           for comparison in subsubdir.comparisons:
00217             test_name=comparison.test_name
00218             test_threshold=comparison.test_thr
00219             break
00220           if len(test_name)!=0:break
00221         if len(test_name)==0:      
00222           for subsubsubdir in subsubdir.subdirs:
00223             for comparison in subsubsubdir.comparisons:
00224               test_name=comparison.test_name
00225               test_threshold=comparison.test_thr
00226               break
00227             if len(test_name)!=0:break
00228 
00229 
00230   meta=directory.meta
00231   
00232   html= '<div class="span-6">'+\
00233         '<h3>Summary</h3>'
00234   html+=get_dir_stats(directory)
00235   html+='<a href="%s/%s">To the DQM GUI...</a>' %(server,base_url)
00236   html+='</div>'
00237         
00238   html+='<div class="span-7 colborder">'+\
00239         '<img src="%s" class="top right">'%directory.get_summary_chart_ajax(200,200)+\
00240         '</div>'+\
00241         '<div class="span-9 last">'
00242   if matrix_page:
00243     html+='<h3>Sample:</h3>'+\
00244           '<p class="caps">%s</p>'%meta.sample+\
00245           '<h3>Run1 and Run2:</h3>'+\
00246           '<p class="caps">%s - %s</p>'%(meta.run1,meta.run2)
00247   html+='<h3>Releases:</h3>'+\
00248         '<ul><li><p>%s</p></li><li><p>%s</p></li></ul>'%(meta.release1,meta.release2)+\
00249         '<h3>Statistical Test (Pvalue threshold):</h3>'+\
00250         '<ul><li><p class="caps">%s (%s)</p></li></ul>'%(test_name,test_threshold)+\
00251         '</div>'+\
00252         '<hr>'
00253   return html
00254 
00255 #-------------------------------------------------------------------------------

def directories2html::get_title_section (   directory,
  depth = 2 
)

Definition at line 118 of file directories2html.py.

00119                                         :
00120   mother_name=basename(directory.mother_dir)
00121   mother_file_name=""
00122   if depth==1:
00123     mother_file_name="../RelMonSummary.html"
00124     if mother_name!="":
00125       mother_file_name="%s.html" %(mother_name)
00126   elif depth==2:
00127     mother_file_name="RelMonSummary.html"
00128     if mother_name!="":
00129       mother_file_name="%s.html" %(mother_name)    
00130   else:
00131       mother_file_name="%s.html" %directory.mother_dir.replace("/","_")
00132       mother_file_name=mother_file_name.strip("_")
00133       
00134   link_to_mother='<a href="%s">..</a>' %mother_file_name
00135   html= '<div class="span-20">'+\
00136         '<h1>%s</h1>'%directory.name+\
00137         '</div>'+\
00138         '<div class="span-1">'+\
00139         '<h1>%s</h1>'%link_to_mother+\
00140         '</div>'+\
00141         '<div class="span-3 last">'+\
00142         '<img src="https://cms-service-reldqm.web.cern.ch/cms-service-reldqm/style/CMS.gif" class="top right" width="54" hight="54">'+\
00143         '</div>'+\
00144         '<hr>' 
00145   if len(mother_name)>0:
00146     html+='<h2 class="alt">%s</h2>'% directory.mother_dir+\
00147           '<hr>' 
00148   return html
00149  
#-------------------------------------------------------------------------------
def directories2html::make_barchart_summary (   dir_dict,
  name = "the_chart",
  title = "DQM directory",
  the_aggr_pairs = [] 
)

Definition at line 607 of file directories2html.py.

00607                                                                                             :  
00608   
00609   aggr_pairs_info= get_aggr_pairs_info(dir_dict,the_aggr_pairs)       
00610 
00611   script="""
00612     <script type="text/javascript" src="https://www.google.com/jsapi"></script>
00613     <script type="text/javascript">
00614       google.load("visualization", "1", {packages:["corechart"]});
00615       google.setOnLoadCallback(drawChart);
00616       function drawChart() {
00617         var data = new google.visualization.DataTable();
00618         data.addColumn('string', 'DQM Directory');
00619         data.addColumn('number', 'Success Rate');
00620         """
00621   script+="data.addRows(%i);\n"%len(aggr_pairs_info)
00622   counter=0
00623   for subsystname,present_directories,weight,success_rate in aggr_pairs_info:
00624     #print subsystname,present_directories
00625     script+="data.setValue(%i, 0, '%s');\n"%(counter,subsystname)
00626     script+="data.setValue(%i, 1, %2.2f);\n"%(counter,success_rate)
00627     counter+=1
00628   script+="""
00629         var chart = new google.visualization.BarChart(document.getElementById('%s'));
00630         chart.draw(data, {width: 1024, height: %i, title: 'Success Rate',
00631                           vAxis: {title: '%s', titleTextStyle: {color: 'red'},textStyle: {fontSize: 14}}
00632                          });
00633       }
00634     </script>
00635     """%(name,40*counter,title)
00636   return script
00637 
00638 
00639 #-------------------------------------------------------------------------------
00640 
def directories2html::make_categories_summary (   dir_dict,
  aggregation_rules 
)

Definition at line 526 of file directories2html.py.

00527                                                        :
00528     
00529   aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
00530   
00531   #print aggr_pairs_info
00532   
00533   # Now Let's build the HTML
00534   
00535   html= '<div class="span-20 colborder">'
00536   html+='<h2 class="alt"><a name="categories">Categories:</a></h2>'
00537 
00538   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00539     #print cat_name,present_subdirs,total_weight,average_success_rate
00540     html+='<div class="span-3 prepend-0 colborder">'
00541     html+='<h3>%s</h3>'%cat_name
00542     html+='<div><span class="alt">Avg. Success rate:</span></div>'
00543     html+='<div><span class="alt">%2.1f%%</span></div>'%(average_success_rate*100)
00544     html+='</div>'    
00545     html+='<div class="span-9">'
00546 
00547     html+='<div><p><span class="caps alt">DQM Directories (%i comparisons):</span></p></div>' %total_weight
00548     html+='<div><p><span class="alt">name: succ. rate - rel. weight</span></p></div>'
00549     html+='<ul>'    
00550     for subdirname in sorted(present_subdirs.keys()):
00551       this_dir_dict=present_subdirs[subdirname]
00552       nsucc=this_dir_dict["nsucc"]
00553       weight=this_dir_dict["weight"]
00554       html+='<li><span class="caps">%s: %2.1f%% - %2.1f%%</span></li>'%(subdirname,100*float(nsucc)/weight,100*float(weight)/total_weight)
00555     html+='</ul>'    
00556     html+='</div>'
00557     
00558     html+='<div class="span-6 last">'
00559     html+=build_gauge(average_success_rate)
00560     html+='</div>'
00561     
00562     html+='<hr>'
00563   return html+'<br><a href="#top">Top...</a> </div><hr>'  
00564     
00565  #-------------------------------------------------------------------------------

def directories2html::make_summary_table (   indir,
  aggregation_rules,
  aggregation_rules_twiki 
)
Create a table, with as rows the directories and as columns the samples.
Each box in the table will contain a pie chart linking to the directory.

Definition at line 641 of file directories2html.py.

00642                                                                        :
00643   """Create a table, with as rows the directories and as columns the samples.
00644   Each box in the table will contain a pie chart linking to the directory.
00645   """  
00646   #aggregation_rules={}
00647   #aggregation_rules_twiki={}
00648 
00649   chdir(indir)
00650   title=indir
00651   title=title.strip(".")
00652   title=title.strip("/")
00653   
00654   
00655   # Get the list of pickles
00656   sample_pkls=filter(lambda name: name.endswith(".pkl"),listdir("./"))
00657   
00658   # Load directories, build a list of all first level subdirs  
00659   dir_unpicklers=[]
00660   n_unpicklers=0
00661   for sample_pkl in sample_pkls:
00662     dir_unpickler=unpickler(sample_pkl)
00663     dir_unpickler.start()
00664     n_unpicklers+=1
00665     dir_unpicklers.append(dir_unpickler)
00666     if n_unpicklers>=1: #pickleing is very expensive. Do not overload cpu
00667       n_unpicklers=0
00668       for dir_unpickler in dir_unpicklers:
00669         dir_unpickler.join()
00670   
00671   dir_dict={}
00672   
00673   # create a fake global directory
00674   global_dir=Directory("global","")  
00675   for dir_unpickler in dir_unpicklers:
00676     dir_unpickler.join()
00677     directory=dir_unpickler.directory
00678     #directory.prune("Run summary")    
00679     #directory.calcStats()
00680     global_dir.meta=directory.meta
00681     dir_dict[dir_unpickler.filename.replace(".pkl","")]=directory
00682     global_dir.subdirs.append(directory)
00683   
00684   global_dir.calcStats()
00685   
00686   directories_barchart=make_barchart_summary(dir_dict,'dir_chart',"DQM Directory")
00687   categories_barchart=make_barchart_summary(dir_dict,'cat_chart','Category',aggregation_rules)
00688   
00689   page_html = get_page_header(additional_header=directories_barchart+categories_barchart)
00690   rel1=""
00691   rel2=""
00692   try:
00693     rel1,rel2=title.split("VS")
00694   except:
00695     rel1=global_dir.meta.release1.split("-")[0]
00696     rel2=global_dir.meta.release2.split("-")[0] 
00697     global_dir.meta.release1=rel1
00698     global_dir.meta.release2=rel2
00699     
00700   # union of all subdirs names
00701   all_subdirs=[]
00702   for directory in dir_dict.values():
00703     for subdir_name in directory.get_subdirs_names():
00704       all_subdirs.append(subdir_name)
00705   all_subdirs=sorted(list(set(all_subdirs)))
00706   
00707   # Get The title
00708   page_html+= '<div class="span-20">'+\
00709               '<h2><a name="top" href="https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon">RelMon</a> Global Report: %s</h2>'%title+\
00710               '</div>'+\
00711               '<div class="span-1">'+\
00712               '<h2><a href="%s">main...</a></h2>' %relmon_mainpage+\
00713               '</div>'+\
00714               '<hr>'
00715   page_html+='<div class="span-24"><p></p></div>\n'*3
00716   
00717   # Get The summary section
00718   page_html+= get_summary_section(global_dir,False)  
00719 
00720   # Make the anchor sections
00721   page_html+= '<div class="span-24">'
00722   page_html+= '<div class="span-20 colborder"><h2 class="alt">Sections:</h2>'+\
00723               '<ul>'+\
00724               '<li><a href="#summary_barchart">Summary Barchart</a></li>'+\
00725               '<li><a href="#categories">Categories</a></li>'+\
00726               '<li><a href="#detailed_barchart">Detailed Barchart</a></li>'+\
00727               '<li><a href="#summary_table">Summary Table</a></li>'+\
00728               '<li><a href="#rank_summary">Ranks Summary</a></li>'+\
00729               '<li><a href="#twiki_table">Twiki Table</a></li>'+\
00730               '</ul>'+\
00731               '</div><hr>'
00732 
00733 
00734   # Make the CategoriesBar chart
00735   page_html+='<div class="span-24"><h2 class="alt"><a name="summary_barchart">Summary Barchart</a></h2></div>'
00736   page_html+='<div id="cat_chart"></div> <a href="#top">Top...</a><hr>'
00737 
00738   # Make the gauges per categories
00739   page_html+=make_categories_summary(dir_dict,aggregation_rules)
00740 
00741   # Make the Directories chart
00742   page_html+='<div class="span-24"><h2 class="alt"><a name="detailed_barchart">Detailed Barchart</a></h2></div>'
00743   page_html+='<div id="dir_chart"></div> <a href="#top">Top...</a><hr>'
00744   
00745   # Barbarian vertical space. Suggestions are welcome
00746   for i in xrange(2):
00747     page_html+='<div class="span-24"><p></p></div>\n'
00748 
00749  
00750   # Prepare the table
00751   page_html+='<div class="span-24"><h2 class="alt"><a name="summary_table">Summary Table</a></h2></div>'
00752 
00753   for i in xrange(5):
00754     page_html+='<div class="span-24"><p></p></div>\n'
00755     
00756   page_html+="""
00757         <table border="1" >
00758           <tr>
00759           <td> </td>          
00760   """
00761   
00762   # First row with samples
00763   page_html+="""
00764           <td><div class="span-1"><p class="rotation" style="alt"><b>Summary</b></p></div></td>"""
00765 
00766   sorted_samples=sorted(dir_dict.keys())
00767   for sample in sorted_samples:
00768     sample_nick=sample
00769     ## For runs: put only the number after the _
00770     #if "_" in sample:
00771       #run_number=sample.split("_")[-1]      
00772       #if (not run_number.isalpha()) and len(run_number)>=6:
00773         #sample_nick=run_number
00774       
00775       
00776     page_html+="""
00777           <td><div class="span-1"><p class="rotation" style="">%s</p></div></td>"""%sample_nick
00778   page_html+="          </tr>\n"
00779 
00780 
00781  # FIRST ROW
00782  # Now the summaries  at the beginning of the table
00783   page_html+="<tr>"
00784   page_html+='<td  style="background-color:white;"><div class="span-1">'
00785   
00786   page_html+='<b>Summary</b></div></td>'
00787   page_html+='<td style="background-color:white;" class = "colborder" ><div class="span-1"><img src="%s" alt="%s"></div></td>'%(global_dir.get_summary_chart_ajax(55,55),get_pie_tooltip(global_dir))
00788   for sample in sorted_samples:
00789     col=dir_dict[sample]
00790     # check if the directory was a top one or not
00791     summary_page_name="RelMonSummary.html"
00792     if col.name!="":
00793       summary_page_name=col.name+".html"
00794     img_link=col.get_summary_chart_ajax(55,55)
00795     page_html+='<td  style="background-color:white;"><div class="span-1">'
00796     page_html+='<a href="%s/%s"><img src="%s" title="%s"></a></div></td>' %(sample,summary_page_name,img_link,get_pie_tooltip(col))
00797   page_html+="</tr>"
00798 
00799   # Now the content
00800   for subdir_name in all_subdirs:  
00801 
00802     page_html+='          <tr>\n'
00803     page_html+='          <td style="background-color:white;">%s</td>\n' %subdir_name  
00804 
00805     row_summary=Directory("row_summary","")
00806     sample_counter=0
00807     n_samples=len(sorted_samples)    
00808 
00809     for sample in sorted_samples:
00810       subdirs_dict=directory.get_subdirs_dict()
00811       directory=dir_dict[sample]
00812       dir_is_there=subdirs_dict.has_key(subdir_name)
00813       if dir_is_there:
00814         row_summary.subdirs.append(subdirs_dict[subdir_name])
00815 
00816     # one first row for the summary!
00817     row_summary.calcStats()
00818     img_link=row_summary.get_summary_chart_ajax(55,55)
00819     page_html+='<td  style="background-color:white;"><div class="span-1">'
00820     page_html+='<img src="%s" title="%s"></div></td>' %(img_link,get_pie_tooltip(row_summary))
00821 
00822     for sample in sorted_samples:
00823       sample_counter+=1      
00824 
00825       directory=dir_dict[sample]
00826       subdirs_dict=directory.get_subdirs_dict()
00827 
00828       # Check if the directory is the top one
00829       summary_page=join(sample,"%s.html"%(subdir_name))
00830       if directory.name!="":
00831         # We did not run on the topdir     
00832         summary_page=join(sample,"%s_%s.html"%(directory.name,subdir_name))
00833       dir_is_there=subdirs_dict.has_key(subdir_name)
00834 
00835       img_link="https://chart.googleapis.com/chart?cht=p3&chco=C0C0C0&chs=50x50&chd=t:1"
00836       img_tooltip="N/A"
00837       if dir_is_there:
00838         #row_summary.subdirs.append(subdirs_dict[subdir_name])
00839         img_link=subdirs_dict[subdir_name].get_summary_chart_ajax(50,50)
00840         img_tooltip=get_pie_tooltip(subdirs_dict[subdir_name])
00841 
00842       page_html+='<td  style="background-color:white;"><div class="span-1">'
00843       if dir_is_there:
00844         page_html+='<a href="%s">'%(summary_page)
00845       page_html+='<img src="%s" title="%s" height=50 width=50>' %(img_link,img_tooltip)
00846       if dir_is_there:
00847         page_html+='</a>'
00848       page_html+='</div></td>' 
00849 
00850     page_html+="          </tr>\n"        
00851 
00852 
00853 
00854   page_html+='</table> <a href="#top">Top...</a><hr>'
00855 
00856   page_html+=get_rank_section(global_dir)
00857 
00858   page_html+=make_twiki_table(dir_dict,aggregation_rules_twiki)
00859 
00860   page_html+=get_page_footer()
00861   return page_html  
def directories2html::make_twiki_table (   dir_dict,
  aggregation_rules 
)

Definition at line 566 of file directories2html.py.

00567                                                 :
00568   
00569   # decide the release
00570   meta= dir_dict.items()[0][1].meta
00571   releases=sorted([meta.release1,meta.release2])
00572   latest_release=releases[1].split("-")[0]
00573   
00574   
00575   aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
00576   
00577   # Now Let's build the HTML
00578   
00579   html= '<div class="span-20 colborder">'
00580   html+='<h2 class="alt"><a name="twiki_table">Twiki snipppet for release managers</a></h2>'
00581   html+='<div>| Release | Comparison |'
00582   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00583     html+=cat_name
00584     html+=" | "
00585   html+='</div>'
00586   
00587   html+='<div>| %s |  %%ICON{arrowdot}%%  | '%latest_release
00588 
00589   # Now add all the line with small gauges
00590 
00591   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00592     #print cat_name,present_subdirs,total_weight,average_success_rate
00593     html+=build_gauge(average_success_rate,small=True,escaped=True)
00594     html+=" | "    
00595   
00596   html+='</div> <a href="#top">Top...</a>'
00597   html+='<hr>'
00598   return html+'</div>'
00599   
00600 #-------------------------------------------------------------------------------

def directories2html::plot_size (   h = 250,
  w = 200 
)

Definition at line 42 of file directories2html.py.

00043                           :
00044   return "w=%s;h=%s" %(h,w)


Variable Documentation

Definition at line 20 of file directories2html.py.