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 hash_name
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 458 of file directories2html.py.

00459                                                                          :
00460   total_success_rate_scaled=(total_success_rate-minrate)
00461   total_success_rate_scaled_repr=total_success_rate_scaled/(1-minrate)
00462   if total_success_rate_scaled_repr<0:
00463     total_success_rate_scaled_repr=0
00464   size_s="200x100"
00465   if small:
00466     size_s="40x30"
00467   #print "Total success rate %2.2f and scaled %2.2f "%(total_success_rate,total_success_rate_scaled)
00468   gauge_link ="https://chart.googleapis.com/chart?chs=%s&cht=gom"%size_s
00469   gauge_link+="&chd=t:%2.1f"%(total_success_rate_scaled_repr*100.)
00470   if not small:
00471     gauge_link+="&chxt=x,y&chxl=0:|%2.1f%%|1:|%i%%|%i%%|100%%"%(total_success_rate*100,minrate*100.,(1+minrate)*50)
00472     gauge_link+="&chma=10,10,10,0"
00473   img_tag= '<img src="%s">'%gauge_link
00474   if escaped:
00475     img_tag=cgi.escape(img_tag)    
00476   return img_tag
00477 
00478 #-------------------------------------------------------------------------------

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

Definition at line 56 of file directories2html.py.

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

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

Definition at line 46 of file directories2html.py.

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

Definition at line 404 of file directories2html.py.

00405                                                :
00406   """Converts a directory tree into html pages, very nice ones.
00407   """
00408   #print "d2html: depth", str(depth)," dir ",directory.name
00409   depth+=1
00410   #old_cwd=getcwd()
00411   #if not exists(directory.name) and len(directory.name)>0:
00412     #makedirs(directory.name)
00413   
00414   #if len(directory.name)>0:
00415     #chdir(directory.name)
00416   
00417   for subdir in directory.subdirs:
00418     directory2html(subdir,hashing, depth)
00419   
00420   page_html=get_page_header(directory)+\
00421             get_title_section(directory,hashing, depth)+\
00422             get_summary_section(directory)+\
00423             get_subdirs_section(directory, hashing)
00424 
00425   for do_cat,cat in ((directory.n_comp_fails >0,FAIL ),
00426                      (directory.n_comp_nulls >0,NULL ),
00427                      
00428                      (directory.n_comp_successes >0 and directory.draw_success,SUCCESS ),
00429                      (directory.n_comp_skiped >0,SKIPED)):
00430     if do_cat:
00431       page_html+=get_comparisons(cat,directory)
00432 
00433   # Distribution of ranks
00434 
00435   if depth==1:
00436     page_html+=get_rank_section(directory)
00437 
00438 
00439   page_html+=get_page_footer()
00440 
00441   page_name=directory.name
00442 
00443   if len(page_name)==0:
00444     page_name="RelMonSummary"
00445   if hashing:
00446       ofilename = "%s.html" %(hash_name(page_name, hashing))
00447   else:
00448       ofilename="%s_%s.html" %(directory.mother_dir.replace("/","_"),page_name)
00449       ofilename=ofilename.strip("_")
00450   #print "Writing on %s" %ofilename
00451   ofile=open(ofilename,"w")
00452   ofile.write(page_html)
00453   ofile.close()
00454 
00455   #chdir(old_cwd)
00456 
00457 #-------------------------------------------------------------------------------

def directories2html::encode_obj_url (   url)

Definition at line 38 of file directories2html.py.

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

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

Definition at line 60 of file directories2html.py.

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

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

Definition at line 69 of file directories2html.py.

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

Definition at line 479 of file directories2html.py.

00480                                                    :
00481   # Let's make a summary for an overview in categories act on the global dir
00482   aggr_pairs_info=[]#(name,{directories names:{nsucc: nsucc,weight:weight}},weight,success_rate)
00483 
00484   list_of_names=[]
00485   if the_aggr_pairs==[]:
00486     for samplename,sampledir in dir_dict.items():
00487       for subsysdirname in sorted(sampledir.get_subdirs_dict().keys()):
00488         if not subsysdirname in list_of_names:
00489           list_of_names.append(subsysdirname)
00490           the_aggr_pairs.append((subsysdirname,[subsysdirname]))  
00491           
00492   #print the_aggr_pairs
00493   for cat_name, subdir_list in the_aggr_pairs:
00494     total_successes=0.
00495     total_directory_successes=0
00496     total_weight=0.    
00497     present_subdirs={}
00498     total_ndirs=0
00499     # Loop on samples
00500     for dirname, sampledir in dir_dict.items():
00501       # Loop on directories
00502       for subdirname,subdir in sampledir.get_subdirs_dict().items():        
00503         if subdirname in subdir_list:          
00504           nsucc=subdir.n_successes
00505           total_successes+=nsucc
00506           weight=subdir.weight
00507           total_weight+=weight
00508           total_ndirs+=1
00509           
00510           total_directory_successes+= float(nsucc)/weight
00511           if present_subdirs.has_key(subdirname):
00512             this_dir_dict=present_subdirs[subdirname]
00513             this_dir_dict["nsucc"]+=nsucc
00514             this_dir_dict["weight"]+=weight
00515           else:
00516             present_subdirs[subdirname]={"nsucc":nsucc,"weight":weight}
00517         # Make it usable also for subdirectories
00518         for subsubdirname,subsubdir in subdir.get_subdirs_dict().items():          
00519           for pathname in filter(lambda name:"/" in name,subdir_list):           
00520             selected_subdirname,selected_subsubdirname = pathname.split("/")
00521             if selected_subdirname == subdirname and selected_subsubdirname==subsubdirname:
00522               #print "Studying directory ",subsubdirname," in directory ",subdirname
00523               nsucc=subsubdir.n_successes
00524               total_successes+=nsucc
00525               weight=subsubdir.weight
00526               total_weight+=weight
00527               total_ndirs+=1              
00528               total_directory_successes+= float(nsucc)/weight
00529               
00530               if present_subdirs.has_key(subsubdirname):
00531                 this_dir_dict=present_subdirs[subsubdirname]
00532                 this_dir_dict["nsucc"]+=nsucc
00533                 this_dir_dict["weight"]+=weight
00534               else:
00535                 present_subdirs[subsubdirname]={"nsucc":nsucc,"weight":weight}      
00536 
00537     if total_ndirs == 0:
00538       print "No directory of the category %s is present in the samples: skipping." %cat_name
00539       continue
00540     
00541     average_success_rate=total_directory_successes/(total_ndirs)
00542     aggr_pairs_info.append((cat_name,present_subdirs,total_weight,average_success_rate))
00543     
00544   return aggr_pairs_info
00545 
00546 #-------------------------------------------------------------------------------

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 272 of file directories2html.py.

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

def directories2html::get_dir_stats (   directory)

Definition at line 161 of file directories2html.py.

00162                             :
00163   html='<p><span class="caps alt">%s comparisons:</span></p>'%directory.weight
00164   html+='<ul>'
00165   if directory.n_successes>0:
00166     html+='<li><span class="caps">Success: %.1f%% (%s)</span></li>'%(directory.get_success_rate(),directory.n_successes)
00167   if directory.n_nulls>0:
00168     html+='<li><span class="caps">Null: %.1f%% (%s)</span></li>'%(directory.get_null_rate(),directory.n_nulls)
00169   if directory.n_fails>0:
00170     html+='<li><span class="caps">Fail: %.1f%% (%s)</span></li>'%(directory.get_fail_rate(),directory.n_fails)
00171   if directory.n_skiped>0:
00172     html+='<li><span class="caps">Skipped: %.1f%% (%s)</span></li>'%(directory.get_skiped_rate(),directory.n_skiped)
00173   html+='</ul>'
00174   return html
00175 
00176 #-------------------------------------------------------------------------------

def directories2html::get_page_footer ( )

Definition at line 115 of file directories2html.py.

00116                      :
00117     return '</div></body></html>'
00118 
00119 #-------------------------------------------------------------------------------

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

Definition at line 79 of file directories2html.py.

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

def directories2html::get_pie_tooltip (   directory)

Definition at line 622 of file directories2html.py.

00623                               :
00624   tooltip="%s\nS:%2.1f%% N:%2.1f%% F:%2.1f%% Sk:%2.1f%%" %(directory.name,directory.get_success_rate(),directory.get_null_rate(),directory.get_fail_rate(),directory.get_skiped_rate())
00625   return tooltip
00626 
00627 #-------------------------------------------------------------------------------

def directories2html::get_rank_section (   directory)

Definition at line 357 of file directories2html.py.

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

def directories2html::get_subdirs_section (   directory,
  hashing_flag 
)

Definition at line 177 of file directories2html.py.

00177                                                 : 
00178   if len(directory.subdirs)==0:
00179     return ""
00180   html= '<div class="span-20 colborder">'
00181   html+='<h2 class="alt">Sub-Directories</h2>'
00182   # sort subdirs according to the number of fails and number of nulls and then alphabveticaly
00183   # so reverse :)
00184   sorted_subdirs= sorted(directory.subdirs, key= lambda subdir: subdir.name)
00185   sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_nulls, reverse=True)
00186   sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_fails, reverse=True)
00187   for subdir in sorted_subdirs:
00188     name=subdir.name
00189     if hashing_flag:
00190         link = "%s.html" %(hash_name(name, hashing_flag))
00191     else:
00192         link="%s_%s_%s.html" %(directory.mother_dir.replace("/","_"),directory.name.replace("/","_"),name)
00193         link=link.strip("_")
00194     html+='<div class="span-4 prepend-2 colborder">'
00195     html+='<h3>%s</h3>'%name
00196     html+='</div>'
00197     
00198     html+='<div class="span-7">'
00199     html+=get_dir_stats(subdir)
00200     html+='</div>'
00201     
00202     html+='<div class="span-6 last">'
00203     html+='<a href="%s"><img src="%s" class="top right"></a>'%(link,subdir.get_summary_chart_ajax(150,100))
00204     html+='</div>'
00205     
00206     html+='<hr>'
00207   return html+'</div>'
00208 
00209  
00210 #-------------------------------------------------------------------------------
00211 
def directories2html::get_summary_section (   directory,
  matrix_page = True 
)

Definition at line 212 of file directories2html.py.

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

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

Definition at line 120 of file directories2html.py.

00121                                                        :
00122   mother_name=basename(directory.mother_dir)
00123   mother_file_name=""
00124   if depth==1:
00125     mother_file_name="../RelMonSummary.html"
00126     if mother_name!="":
00127       mother_file_name="%s.html" %(hash_name(mother_name, hashing_flag))
00128   elif depth==2:
00129     #mother_file_name="RelMonSummary.html"
00130     mother_file_name="%s.html" %(hash_name("RelMonSummary", hashing_flag))
00131     if mother_name!="":
00132       mother_file_name="%s.html" %(hash_name(mother_name, hashing_flag))
00133   else:
00134       if hashing_flag:
00135           files = directory.mother_dir.split("/")
00136           if len(files) != 1:
00137               dir_name = files[-2] ##return the mother directory name only as the html file name by it
00138           else:
00139               dir_name = files[-1]
00140           mother_file_name="%s.html" %(hash_name(dir_name, hashing_flag))
00141       else:
00142           mother_file_name="%s.html" %directory.mother_dir.replace("/","_")
00143           mother_file_name=mother_file_name.strip("_")
00144       
00145   link_to_mother='<a href="%s">..</a>' %mother_file_name
00146   html= '<div class="span-20">'+\
00147         '<h1>%s</h1>'%directory.name+\
00148         '</div>'+\
00149         '<div class="span-1">'+\
00150         '<h1>%s</h1>'%link_to_mother+\
00151         '</div>'+\
00152         '<div class="span-3 last">'+\
00153         '<img src="cms-service-reldqm/style/CMS.gif" class="top right" width="54" hight="54">'+\
00154         '</div>'+\
00155         '<hr>' 
00156   if len(mother_name)>0:
00157     html+='<h2 class="alt">%s</h2>'% directory.mother_dir+\
00158           '<hr>' 
00159   return html
00160  
#-------------------------------------------------------------------------------
def directories2html::hash_name (   file_name,
  flag 
)

Definition at line 888 of file directories2html.py.

00889                               :
00890     if flag: #if hashing flag is ON then return
00891         return hashlib.md5(file_name).hexdigest()[:10] #md5 hashed file name with length 10
00892     else:
00893         return file_name #return standart name
def directories2html::make_barchart_summary (   dir_dict,
  name = "the_chart",
  title = "DQM directory",
  the_aggr_pairs = [] 
)

Definition at line 628 of file directories2html.py.

00628                                                                                             :  
00629   
00630   aggr_pairs_info= get_aggr_pairs_info(dir_dict,the_aggr_pairs)       
00631 
00632   script="""
00633     <script type="text/javascript" src="https://www.google.com/jsapi"></script>
00634     <script type="text/javascript">
00635       google.load("visualization", "1", {packages:["corechart"]});
00636       google.setOnLoadCallback(drawChart);
00637       function drawChart() {
00638         var data = new google.visualization.DataTable();
00639         data.addColumn('string', 'DQM Directory');
00640         data.addColumn('number', 'Success Rate');
00641         """
00642   script+="data.addRows(%i);\n"%len(aggr_pairs_info)
00643   counter=0
00644   for subsystname,present_directories,weight,success_rate in aggr_pairs_info:
00645     #print subsystname,present_directories
00646     script+="data.setValue(%i, 0, '%s');\n"%(counter,subsystname)
00647     script+="data.setValue(%i, 1, %2.2f);\n"%(counter,success_rate)
00648     counter+=1
00649   script+="""
00650         var chart = new google.visualization.BarChart(document.getElementById('%s'));
00651         chart.draw(data, {width: 1024, height: %i, title: 'Success Rate',
00652                           vAxis: {title: '%s', titleTextStyle: {color: 'red'},textStyle: {fontSize: 14}}
00653                          });
00654       }
00655     </script>
00656     """%(name,40*counter,title)
00657   return script
00658 
00659 
00660 #-------------------------------------------------------------------------------
00661 
def directories2html::make_categories_summary (   dir_dict,
  aggregation_rules 
)

Definition at line 547 of file directories2html.py.

00548                                                        :
00549     
00550   aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
00551   
00552   #print aggr_pairs_info
00553   
00554   # Now Let's build the HTML
00555   
00556   html= '<div class="span-20 colborder">'
00557   html+='<h2 class="alt"><a name="categories">Categories:</a></h2>'
00558 
00559   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00560     #print cat_name,present_subdirs,total_weight,average_success_rate
00561     html+='<div class="span-3 prepend-0 colborder">'
00562     html+='<h3>%s</h3>'%cat_name
00563     html+='<div><span class="alt">Avg. Success rate:</span></div>'
00564     html+='<div><span class="alt">%2.1f%%</span></div>'%(average_success_rate*100)
00565     html+='</div>'    
00566     html+='<div class="span-9">'
00567 
00568     html+='<div><p><span class="caps alt">DQM Directories (%i comparisons):</span></p></div>' %total_weight
00569     html+='<div><p><span class="alt">name: succ. rate - rel. weight</span></p></div>'
00570     html+='<ul>'    
00571     for subdirname in sorted(present_subdirs.keys()):
00572       this_dir_dict=present_subdirs[subdirname]
00573       nsucc=this_dir_dict["nsucc"]
00574       weight=this_dir_dict["weight"]
00575       html+='<li><span class="caps">%s: %2.1f%% - %2.1f%%</span></li>'%(subdirname,100*float(nsucc)/weight,100*float(weight)/total_weight)
00576     html+='</ul>'    
00577     html+='</div>'
00578     
00579     html+='<div class="span-6 last">'
00580     html+=build_gauge(average_success_rate)
00581     html+='</div>'
00582     
00583     html+='<hr>'
00584   return html+'<br><a href="#top">Top...</a> </div><hr>'  
00585     
00586  #-------------------------------------------------------------------------------

def directories2html::make_summary_table (   indir,
  aggregation_rules,
  aggregation_rules_twiki,
  hashing_flag 
)
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 662 of file directories2html.py.

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

Definition at line 587 of file directories2html.py.

00588                                                 :
00589   
00590   # decide the release
00591   meta= dir_dict.items()[0][1].meta
00592   releases=sorted([meta.release1,meta.release2])
00593   latest_release=releases[1].split("-")[0]
00594   
00595   
00596   aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
00597   
00598   # Now Let's build the HTML
00599   
00600   html= '<div class="span-20 colborder">'
00601   html+='<h2 class="alt"><a name="twiki_table">Twiki snipppet for release managers</a></h2>'
00602   html+='<div>| Release | Comparison |'
00603   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00604     html+=cat_name
00605     html+=" | "
00606   html+='</div>'
00607   
00608   html+='<div>| %s |  %%ICON{arrowdot}%%  | '%latest_release
00609 
00610   # Now add all the line with small gauges
00611 
00612   for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
00613     #print cat_name,present_subdirs,total_weight,average_success_rate
00614     html+=build_gauge(average_success_rate,small=True,escaped=True)
00615     html+=" | "    
00616   
00617   html+='</div> <a href="#top">Top...</a>'
00618   html+='<hr>'
00619   return html+'</div>'
00620   
00621 #-------------------------------------------------------------------------------

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

Definition at line 43 of file directories2html.py.

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


Variable Documentation

Definition at line 20 of file directories2html.py.