CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.

Referenced by make_categories_summary(), and make_twiki_table().

459 def build_gauge(total_success_rate,minrate=.80,small=False,escaped=False):
460  total_success_rate_scaled=(total_success_rate-minrate)
461  total_success_rate_scaled_repr=total_success_rate_scaled/(1-minrate)
462  if total_success_rate_scaled_repr<0:
463  total_success_rate_scaled_repr=0
464  size_s="200x100"
465  if small:
466  size_s="40x30"
467  #print "Total success rate %2.2f and scaled %2.2f "%(total_success_rate,total_success_rate_scaled)
468  gauge_link ="https://chart.googleapis.com/chart?chs=%s&cht=gom"%size_s
469  gauge_link+="&chd=t:%2.1f"%(total_success_rate_scaled_repr*100.)
470  if not small:
471  gauge_link+="&chxt=x,y&chxl=0:|%2.1f%%|1:|%i%%|%i%%|100%%"%(total_success_rate*100,minrate*100.,(1+minrate)*50)
472  gauge_link+="&chma=10,10,10,0"
473  img_tag= '<img src="%s">'%gauge_link
474  if escaped:
475  img_tag=cgi.escape(img_tag)
476  return img_tag
477 
478 #-------------------------------------------------------------------------------
def directories2html.build_obj (   run,
  sample,
  version,
  plot_path,
  tier 
)

Definition at line 56 of file directories2html.py.

References build_obj_addr(), and encode_obj_url().

Referenced by fairy_url().

56 
57 def build_obj(run,sample,version,plot_path,tier):
58  obj_url="obj=%s;" %build_obj_addr(run,sample,version,plot_path,tier)
59  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.

Referenced by build_obj(), and fairy_url_single().

46 
47 def build_obj_addr(run,sample,version,plot_path,tier):
48  slash="/"
49  obj_url="archive/%s/%s/%s/%s/" %(run,sample,version,tier)
50  obj_url+=plot_path
51  while obj_url.endswith(slash):
52  obj_url=obj_url[:-1]
53  while slash*2 in obj_url:
54  obj_url=obj_url.replace(slash*2,slash)
55  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.

References get_comparisons(), get_page_footer(), get_page_header(), get_rank_section(), get_subdirs_section(), get_summary_section(), get_title_section(), and hash_name().

405 def directory2html(directory, hashing, depth=0):
406  """Converts a directory tree into html pages, very nice ones.
407  """
408  #print "d2html: depth", str(depth)," dir ",directory.name
409  depth+=1
410  #old_cwd=getcwd()
411  #if not exists(directory.name) and len(directory.name)>0:
412  #makedirs(directory.name)
413 
414  #if len(directory.name)>0:
415  #chdir(directory.name)
416 
417  for subdir in directory.subdirs:
418  directory2html(subdir,hashing, depth)
419 
420  page_html=get_page_header(directory)+\
421  get_title_section(directory,hashing, depth)+\
422  get_summary_section(directory)+\
423  get_subdirs_section(directory, hashing)
424 
425  for do_cat,cat in ((directory.n_comp_fails >0,FAIL ),
426  (directory.n_comp_nulls >0,NULL ),
427 
428  (directory.n_comp_successes >0 and directory.draw_success,SUCCESS ),
429  (directory.n_comp_skiped >0,SKIPED)):
430  if do_cat:
431  page_html+=get_comparisons(cat,directory)
432 
433  # Distribution of ranks
434 
435  if depth==1:
436  page_html+=get_rank_section(directory)
437 
438 
439  page_html+=get_page_footer()
440 
441  page_name=directory.name
442 
443  if len(page_name)==0:
444  page_name="RelMonSummary"
445  if hashing:
446  ofilename = "%s.html" %(hash_name(page_name, hashing))
447  else:
448  ofilename="%s_%s.html" %(directory.mother_dir.replace("/","_"),page_name)
449  ofilename=ofilename.strip("_")
450  #print "Writing on %s" %ofilename
451  ofile=open(ofilename,"w")
452  ofile.write(page_html)
453  ofile.close()
454 
455  #chdir(old_cwd)
456 
457 #-------------------------------------------------------------------------------
def directories2html.encode_obj_url (   url)

Definition at line 38 of file directories2html.py.

Referenced by build_obj().

38 
39 def encode_obj_url(url):
40  for old,new in url_encode_dict.items():
41  url=url.replace(old,new)
42  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.

References build_obj(), and plot_size().

Referenced by get_comparisons().

60 
61 def fairy_url(run,sample,version1,version2,plot_path,tier1,tier2,draw_opts="",h=250,w=200):
62  fairy_url = "%s/%s/plotfairy/overlay?" %(server,base_url)
63  fairy_url+= build_obj(run,sample,version1,plot_path,tier1)
64  fairy_url+= build_obj(run,sample,version2,plot_path,tier2)
65  if len(draw_opts)>0:
66  fairy_url+="drawopts=%s;" %draw_opts
67  fairy_url+= plot_size(h,w)
68  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.

References build_obj_addr(), and plot_size().

Referenced by get_comparisons().

69 
70 def fairy_url_single(run,sample,version,plot_path,tier,draw_opts="",h=250,w=200):
71  fairy_url = "%s/%s/plotfairy/" %(server,base_url)
72  fairy_url+=build_obj_addr(run,sample,version,plot_path,tier)
73  fairy_url+= "?%s"%plot_size(h,w)
74  if len(draw_opts)>0:
75  fairy_url+="drawopts=%s;" %draw_opts
76  return fairy_url
77 
78 #-------------------------------------------------------------------------------
style_location="/cms-service-reldqm"
def directories2html.get_aggr_pairs_info (   dir_dict,
  the_aggr_pairs = [] 
)

Definition at line 479 of file directories2html.py.

References alcazmumu_cfi.filter, and relativeConstraints.keys.

Referenced by make_barchart_summary(), make_categories_summary(), and make_twiki_table().

480 def get_aggr_pairs_info(dir_dict,the_aggr_pairs=[]):
481  # Let's make a summary for an overview in categories act on the global dir
482  aggr_pairs_info=[]#(name,{directories names:{nsucc: nsucc,weight:weight}},weight,success_rate)
483 
484  list_of_names=[]
485  if the_aggr_pairs==[]:
486  for samplename,sampledir in dir_dict.items():
487  for subsysdirname in sorted(sampledir.get_subdirs_dict().keys()):
488  if not subsysdirname in list_of_names:
489  list_of_names.append(subsysdirname)
490  the_aggr_pairs.append((subsysdirname,[subsysdirname]))
491 
492  #print the_aggr_pairs
493  for cat_name, subdir_list in the_aggr_pairs:
494  total_successes=0.
495  total_directory_successes=0
496  total_weight=0.
497  present_subdirs={}
498  total_ndirs=0
499  # Loop on samples
500  for dirname, sampledir in dir_dict.items():
501  # Loop on directories
502  for subdirname,subdir in sampledir.get_subdirs_dict().items():
503  if subdirname in subdir_list:
504  nsucc=subdir.n_successes
505  total_successes+=nsucc
506  weight=subdir.weight
507  total_weight+=weight
508  total_ndirs+=1
509 
510  total_directory_successes+= float(nsucc)/weight
511  if present_subdirs.has_key(subdirname):
512  this_dir_dict=present_subdirs[subdirname]
513  this_dir_dict["nsucc"]+=nsucc
514  this_dir_dict["weight"]+=weight
515  else:
516  present_subdirs[subdirname]={"nsucc":nsucc,"weight":weight}
517  # Make it usable also for subdirectories
518  for subsubdirname,subsubdir in subdir.get_subdirs_dict().items():
519  for pathname in filter(lambda name:"/" in name,subdir_list):
520  selected_subdirname,selected_subsubdirname = pathname.split("/")
521  if selected_subdirname == subdirname and selected_subsubdirname==subsubdirname:
522  #print "Studying directory ",subsubdirname," in directory ",subdirname
523  nsucc=subsubdir.n_successes
524  total_successes+=nsucc
525  weight=subsubdir.weight
526  total_weight+=weight
527  total_ndirs+=1
528  total_directory_successes+= float(nsucc)/weight
529 
530  if present_subdirs.has_key(subsubdirname):
531  this_dir_dict=present_subdirs[subsubdirname]
532  this_dir_dict["nsucc"]+=nsucc
533  this_dir_dict["weight"]+=weight
534  else:
535  present_subdirs[subsubdirname]={"nsucc":nsucc,"weight":weight}
536 
537  if total_ndirs == 0:
538  print "No directory of the category %s is present in the samples: skipping." %cat_name
539  continue
540 
541  average_success_rate=total_directory_successes/(total_ndirs)
542  aggr_pairs_info.append((cat_name,present_subdirs,total_weight,average_success_rate))
543 
544  return aggr_pairs_info
545 
546 #-------------------------------------------------------------------------------
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.

References fairy_url(), and fairy_url_single().

Referenced by directory2html().

273 def get_comparisons(category,directory):
274  """Prepare the comparisons between histograms and organise them in the page.
275  Moreover create separate pages with the overlay and the single plots.
276  """
277  counter=1
278  tot_counter=1
279 
280  # get the right ones
281  comparisons= filter (lambda comp: comp.status == cat_states[category] , directory.comparisons)
282  n_comparisons=len(comparisons)
283 
284  is_reverse=True
285  if category == FAIL:
286  is_reverse=False
287  comparisons=sorted(comparisons, key=lambda comp:comp.rank, reverse=is_reverse)
288 
289 
290  dir_abs_path="%s/%s/" %(directory.mother_dir,directory.name)
291  html_comparisons=""
292  for comparison in comparisons:
293  plot_name=comparison.img_name
294  if "http://" not in plot_name:
295  plot_name= basename(comparison.img_name)
296  class_type="colborder"
297  if counter==3 or tot_counter==n_comparisons:
298  class_type=" colborder last"
299  comp_abs_path="%s/%s" %(dir_abs_path,comparison.name)
300 
301 
302  if directory.do_pngs:
303  png_link=comparison.img_name
304  html_comparisons+='<div class="span-6 %s"><p>%s</p>' %(class_type,comparison.name)+\
305  '<p class="alt">%s: %.2E</p>' %(comparison.test_name,comparison.rank)+\
306  '<a href="%s"><img src="%s" width="250" height="200" class="top center %s"></a></div>'%(png_link,png_link,cat_classes[category])
307  else:
308  big_fairy=fairy_url(directory.meta.run1,
309  directory.meta.sample,
310  directory.meta.release1,
311  directory.meta.release2,
312  comp_abs_path,
313  directory.meta.tier1,
314  directory.meta.tier2,
315  "",600,600)
316  small_fairy=fairy_url(directory.meta.run1,
317  directory.meta.sample,
318  directory.meta.release1,
319  directory.meta.release2,
320  comp_abs_path,
321  directory.meta.tier1,
322  directory.meta.tier2)
323 
324  single_fairy1=fairy_url_single(directory.meta.run1,
325  directory.meta.sample,
326  directory.meta.release1,
327  comp_abs_path,
328  directory.meta.tier1,
329  "",500,500)
330  single_fairy2=fairy_url_single(directory.meta.run2,
331  directory.meta.sample,
332  directory.meta.release2,
333  comp_abs_path,
334  directory.meta.tier2,
335  "",500,500)
336 
337  html_comparisons+='<div class="span-6 %s"><p>%s</p>' %(class_type,comparison.name)+\
338  '<p class="alt">%s: %.2E</p>' %(comparison.test_name,comparison.rank)+\
339  '<div><a class="black_link" href="%s">%s</a></div>'%(single_fairy1,directory.meta.release1)+\
340  '<div><a href="%s">%s</a></div>'%(single_fairy2,directory.meta.release2)+\
341  '<a href="%s"><img src="%s" class="top center %s"></a></div>'%(big_fairy,small_fairy,cat_classes[category])
342 
343  if counter==3:
344  html_comparisons+="<hr>"
345  counter=0
346  counter+=1
347  tot_counter+=1
348 
349  if len(html_comparisons)!=0:
350  html='<div class="span-20"><h2 class="alt">%s Comparisons</h2></div>' %cat_names[category]
351  html+=html_comparisons
352  html+='<hr>'
353  return html
354  return ""
355 
356 #-------------------------------------------------------------------------------
def directories2html.get_dir_stats (   directory)

Definition at line 161 of file directories2html.py.

Referenced by get_subdirs_section(), and get_summary_section().

162 def get_dir_stats(directory):
163  html='<p><span class="caps alt">%s comparisons:</span></p>'%directory.weight
164  html+='<ul>'
165  if directory.n_successes>0:
166  html+='<li><span class="caps">Success: %.1f%% (%s)</span></li>'%(directory.get_success_rate(),directory.n_successes)
167  if directory.n_nulls>0:
168  html+='<li><span class="caps">Null: %.1f%% (%s)</span></li>'%(directory.get_null_rate(),directory.n_nulls)
169  if directory.n_fails>0:
170  html+='<li><span class="caps">Fail: %.1f%% (%s)</span></li>'%(directory.get_fail_rate(),directory.n_fails)
171  if directory.n_skiped>0:
172  html+='<li><span class="caps">Skipped: %.1f%% (%s)</span></li>'%(directory.get_skiped_rate(),directory.n_skiped)
173  html+='</ul>'
174  return html
175 
176 #-------------------------------------------------------------------------------
def directories2html.get_page_footer ( )

Definition at line 115 of file directories2html.py.

Referenced by directory2html(), and make_summary_table().

116 def get_page_footer():
117  return '</div></body></html>'
118 
119 #-------------------------------------------------------------------------------
def directories2html.get_page_header (   directory = None,
  additional_header = "" 
)

Definition at line 79 of file directories2html.py.

Referenced by directory2html(), and make_summary_table().

79 
80 def get_page_header(directory=None,additional_header=""):
81  javascripts=''
82  style=''
83  if directory!=None and len(directory.comparisons)>0:
84  meta=directory.meta
85  style='img.fail {border:1px solid #ff0000;}\n'+\
86  'img.succes {border:1px solid #00ff00;}\n'+\
87  'img.null {border:1px solid #ffff00;}\n'+\
88  'img.skiped {border:1px solid #7a7a7a;}\n'+\
89  'a.black_link:link {color: #333333}\n'+\
90  'a.black_link:hover {color: #737373}\n'+\
91  'a.black_link:visited {color: #333333}\n'+\
92  'a.black_link:active {color: #333333}\n'
93  javascripts=""
94 
95 
96  html='<html>'+\
97  '<head>'+\
98  '<title>RelMon Summary</title>'+\
99  '<link rel="stylesheet" href="%s/style/blueprint/screen.css" type="text/css" media="screen, projection">'%style_location+\
100  '<link rel="stylesheet" href="%s/style/blueprint/print.css" type="text/css" media="print">'%style_location+\
101  '<link rel="stylesheet" href="%s/style/blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">'%style_location+\
102  '<style type="text/css">'+\
103  '.rotation {display: block;-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg); }'+\
104  '%s'%style+\
105  '</style>'+\
106  '%s'%javascripts+\
107  '%s'%additional_header+\
108  '</head>'+\
109  '<body>'+\
110  '<div class="container">'
111 
112  return html
113 
114 #-------------------------------------------------------------------------------
def directories2html.get_pie_tooltip (   directory)

Definition at line 622 of file directories2html.py.

Referenced by make_summary_table().

623 def get_pie_tooltip(directory):
624  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())
625  return tooltip
626 
627 #-------------------------------------------------------------------------------
def directories2html.get_rank_section (   directory)

Definition at line 357 of file directories2html.py.

Referenced by directory2html(), and make_summary_table().

358 def get_rank_section(directory):
359 # do Rank histo png
360  imgname="RankSummary.png"
361  gStyle.SetPadTickY(0)
362  c=TCanvas("ranks","ranks",500,400)
363  #gStyle.SetOptStat(0)
364  c.cd()
365 
366  h=directory.rank_histo
367  rank_histof=TH1F(h.GetName(),"",h.GetNbinsX(),h.GetXaxis().GetXmin(),h.GetXaxis().GetXmax())
368  rank_histof.SetLineWidth(2)
369  for i in xrange(0,h.GetNbinsX()+1):
370  rank_histof.SetBinContent(i,h.GetBinContent(i))
371  h.SetTitle("Ranks Summary;Rank;Frequency")
372  h.Draw("Hist")
373  c.Update()
374  rank_histof.ComputeIntegral()
375  integral = rank_histof.GetIntegral()
376  rank_histof.SetContent(integral)
377 
378  rightmax = 1.1*rank_histof.GetMaximum()
379  scale = gPad.GetUymax()/rightmax
380  rank_histof.SetLineColor(kRed)
381  rank_histof.Scale(scale)
382  rank_histof.Draw("same")
383 
384  #draw an axis on the right side
385  axis = TGaxis(gPad.GetUxmax(),gPad.GetUymin(),gPad.GetUxmax(), gPad.GetUymax(),0,rightmax,510,"+L")
386  axis.SetTitle("Cumulative")
387  axis.SetTitleColor(kRed)
388  axis.SetLineColor(kRed)
389  axis.SetLabelColor(kRed)
390  axis.Draw()
391 
392  rank_histof.Draw("Same");
393 
394 
395  c.Print(imgname)
396 
397  page_html='<div class="span-20"><h2 class="alt"><a name="rank_summary">Ranks Summary</a></h2>'
398  page_html+='<div class="span-19"><img src="%s"></div>' %imgname
399  page_html+='</div> <a href="#top">Top...</a><hr>'
400 
401  return page_html
402 
403 #-------------------------------------------------------------------------------
def directories2html.get_subdirs_section (   directory,
  hashing_flag 
)

Definition at line 177 of file directories2html.py.

References get_dir_stats(), and hash_name().

Referenced by directory2html().

178 def get_subdirs_section(directory, hashing_flag):
179  if len(directory.subdirs)==0:
180  return ""
181  html= '<div class="span-20 colborder">'
182  html+='<h2 class="alt">Sub-Directories</h2>'
183  # sort subdirs according to the number of fails and number of nulls and then alphabveticaly
184  # so reverse :)
185  sorted_subdirs= sorted(directory.subdirs, key= lambda subdir: subdir.name)
186  sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_nulls, reverse=True)
187  sorted_subdirs= sorted(sorted_subdirs, key= lambda subdir: subdir.n_fails, reverse=True)
188  for subdir in sorted_subdirs:
189  name=subdir.name
190  if hashing_flag:
191  link = "%s.html" %(hash_name(name, hashing_flag))
192  else:
193  link="%s_%s_%s.html" %(directory.mother_dir.replace("/","_"),directory.name.replace("/","_"),name)
194  link=link.strip("_")
195  html+='<div class="span-4 prepend-2 colborder">'
196  html+='<h3>%s</h3>'%name
197  html+='</div>'
198 
199  html+='<div class="span-7">'
200  html+=get_dir_stats(subdir)
201  html+='</div>'
202 
203  html+='<div class="span-6 last">'
204  html+='<a href="%s"><img src="%s" class="top right"></a>'%(link,subdir.get_summary_chart_ajax(150,100))
205  html+='</div>'
206 
207  html+='<hr>'
208  return html+'</div>'
209 
210 
211 #-------------------------------------------------------------------------------
def directories2html.get_summary_section (   directory,
  matrix_page = True 
)

Definition at line 212 of file directories2html.py.

References get_dir_stats().

Referenced by directory2html(), and make_summary_table().

213 def get_summary_section(directory,matrix_page=True):
214 
215  # Hack find the first comparison and fill test and threshold
216  # shall this be put in meta?
217  test_name=""
218  test_threshold=0
219  for comparison in directory.comparisons:
220  test_name=comparison.test_name
221  test_threshold=comparison.test_thr
222  break
223  if len(test_name)==0:
224  for subdir in directory.subdirs:
225  for comparison in subdir.comparisons:
226  test_name=comparison.test_name
227  test_threshold=comparison.test_thr
228  break
229  if len(test_name)!=0:break
230  if len(test_name)==0:
231  for subsubdir in subdir.subdirs:
232  for comparison in subsubdir.comparisons:
233  test_name=comparison.test_name
234  test_threshold=comparison.test_thr
235  break
236  if len(test_name)!=0:break
237  if len(test_name)==0:
238  for subsubsubdir in subsubdir.subdirs:
239  for comparison in subsubsubdir.comparisons:
240  test_name=comparison.test_name
241  test_threshold=comparison.test_thr
242  break
243  if len(test_name)!=0:break
244 
245 
246  meta=directory.meta
247 
248  html= '<div class="span-6">'+\
249  '<h3>Summary</h3>'
250  html+=get_dir_stats(directory)
251  html+='<a href="%s/%s">To the DQM GUI...</a>' %(server,base_url)
252  html+='</div>'
253 
254  html+='<div class="span-7 colborder">'+\
255  '<img src="%s" class="top right">'%directory.get_summary_chart_ajax(200,200)+\
256  '</div>'+\
257  '<div class="span-9 last">'
258  if matrix_page:
259  html+='<h3>Sample:</h3>'+\
260  '<p class="caps">%s</p>'%meta.sample+\
261  '<h3>Run1 and Run2:</h3>'+\
262  '<p class="caps">%s - %s</p>'%(meta.run1,meta.run2)
263  html+='<h3>Releases:</h3>'+\
264  '<ul><li><p>%s</p></li><li><p>%s</p></li></ul>'%(meta.release1,meta.release2)+\
265  '<h3>Statistical Test (Pvalue threshold):</h3>'+\
266  '<ul><li><p class="caps">%s (%s)</p></li></ul>'%(test_name,test_threshold)+\
267  '</div>'+\
268  '<hr>'
269  return html
270 
271 #-------------------------------------------------------------------------------
def directories2html.get_title_section (   directory,
  hashing_flag,
  depth = 2 
)

Definition at line 120 of file directories2html.py.

References hash_name().

Referenced by directory2html().

121 def get_title_section(directory, hashing_flag, depth=2):
122  mother_name=basename(directory.mother_dir)
123  mother_file_name=""
124  if depth==1:
125  mother_file_name="../RelMonSummary.html"
126  if mother_name!="":
127  mother_file_name="%s.html" %(hash_name(mother_name, hashing_flag))
128  elif depth==2:
129  #mother_file_name="RelMonSummary.html"
130  mother_file_name="%s.html" %(hash_name("RelMonSummary", hashing_flag))
131  if mother_name!="":
132  mother_file_name="%s.html" %(hash_name(mother_name, hashing_flag))
133  else:
134  if hashing_flag:
135  files = directory.mother_dir.split("/")
136  if len(files) != 1:
137  dir_name = files[-2] ##return the mother directory name only as the html file name by it
138  else:
139  dir_name = files[-1]
140  mother_file_name="%s.html" %(hash_name(dir_name, hashing_flag))
141  else:
142  mother_file_name="%s.html" %directory.mother_dir.replace("/","_")
143  mother_file_name=mother_file_name.strip("_")
144 
145  link_to_mother='<a href="%s">..</a>' %mother_file_name
146  html= '<div class="span-20">'+\
147  '<h1>%s</h1>'%directory.name+\
148  '</div>'+\
149  '<div class="span-1">'+\
150  '<h1>%s</h1>'%link_to_mother+\
151  '</div>'+\
152  '<div class="span-3 last">'+\
153  '<img src="cms-service-reldqm/style/CMS.gif" class="top right" width="54" hight="54">'+\
154  '</div>'+\
155  '<hr>'
156  if len(mother_name)>0:
157  html+='<h2 class="alt">%s</h2>'% directory.mother_dir+\
158  '<hr>'
159  return html
160 
#-------------------------------------------------------------------------------
def directories2html.hash_name (   file_name,
  flag 
)

Definition at line 888 of file directories2html.py.

Referenced by directory2html(), get_subdirs_section(), get_title_section(), and make_summary_table().

889 def hash_name(file_name, flag):
890  if flag: #if hashing flag is ON then return
891  return hashlib.md5(file_name).hexdigest()[:10] #md5 hashed file name with length 10
892  else:
893  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.

References get_aggr_pairs_info().

Referenced by make_summary_table().

629 def make_barchart_summary(dir_dict,name="the_chart",title="DQM directory",the_aggr_pairs=[]):
630 
631  aggr_pairs_info= get_aggr_pairs_info(dir_dict,the_aggr_pairs)
632 
633  script="""
634  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
635  <script type="text/javascript">
636  google.load("visualization", "1", {packages:["corechart"]});
637  google.setOnLoadCallback(drawChart);
638  function drawChart() {
639  var data = new google.visualization.DataTable();
640  data.addColumn('string', 'DQM Directory');
641  data.addColumn('number', 'Success Rate');
642  """
643  script+="data.addRows(%i);\n"%len(aggr_pairs_info)
644  counter=0
645  for subsystname,present_directories,weight,success_rate in aggr_pairs_info:
646  #print subsystname,present_directories
647  script+="data.setValue(%i, 0, '%s');\n"%(counter,subsystname)
648  script+="data.setValue(%i, 1, %2.2f);\n"%(counter,success_rate)
649  counter+=1
650  script+="""
651  var chart = new google.visualization.BarChart(document.getElementById('%s'));
652  chart.draw(data, {width: 1024, height: %i, title: 'Success Rate',
653  vAxis: {title: '%s', titleTextStyle: {color: 'red'},textStyle: {fontSize: 14}}
654  });
655  }
656  </script>
657  """%(name,40*counter,title)
658  return script
659 
660 
661 #-------------------------------------------------------------------------------
def directories2html.make_categories_summary (   dir_dict,
  aggregation_rules 
)

Definition at line 547 of file directories2html.py.

References build_gauge(), and get_aggr_pairs_info().

Referenced by make_summary_table().

548 def make_categories_summary(dir_dict,aggregation_rules):
549 
550  aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
551 
552  #print aggr_pairs_info
553 
554  # Now Let's build the HTML
555 
556  html= '<div class="span-20 colborder">'
557  html+='<h2 class="alt"><a name="categories">Categories:</a></h2>'
558 
559  for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
560  #print cat_name,present_subdirs,total_weight,average_success_rate
561  html+='<div class="span-3 prepend-0 colborder">'
562  html+='<h3>%s</h3>'%cat_name
563  html+='<div><span class="alt">Avg. Success rate:</span></div>'
564  html+='<div><span class="alt">%2.1f%%</span></div>'%(average_success_rate*100)
565  html+='</div>'
566  html+='<div class="span-9">'
567 
568  html+='<div><p><span class="caps alt">DQM Directories (%i comparisons):</span></p></div>' %total_weight
569  html+='<div><p><span class="alt">name: succ. rate - rel. weight</span></p></div>'
570  html+='<ul>'
571  for subdirname in sorted(present_subdirs.keys()):
572  this_dir_dict=present_subdirs[subdirname]
573  nsucc=this_dir_dict["nsucc"]
574  weight=this_dir_dict["weight"]
575  html+='<li><span class="caps">%s: %2.1f%% - %2.1f%%</span></li>'%(subdirname,100*float(nsucc)/weight,100*float(weight)/total_weight)
576  html+='</ul>'
577  html+='</div>'
578 
579  html+='<div class="span-6 last">'
580  html+=build_gauge(average_success_rate)
581  html+='</div>'
582 
583  html+='<hr>'
584  return html+'<br><a href="#top">Top...</a> </div><hr>'
585 
586  #-------------------------------------------------------------------------------
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.

References alcazmumu_cfi.filter, get_page_footer(), get_page_header(), get_pie_tooltip(), get_rank_section(), get_summary_section(), hash_name(), join(), list(), make_barchart_summary(), make_categories_summary(), make_twiki_table(), and runtimedef.set().

Referenced by ValidationMatrix.do_html().

663 def make_summary_table(indir,aggregation_rules,aggregation_rules_twiki, hashing_flag):
664  """Create a table, with as rows the directories and as columns the samples.
665  Each box in the table will contain a pie chart linking to the directory.
666  """
667  #aggregation_rules={}
668  #aggregation_rules_twiki={}
669 
670  chdir(indir)
671  if os.path.isabs(indir):
672  title = basename(indir)
673  else:
674  title=indir
675  title=title.strip(".")
676  title=title.strip("/")
677 
678 
679  # Get the list of pickles
680  sample_pkls=filter(lambda name: name.endswith(".pkl"),listdir("./"))
681 
682  # Load directories, build a list of all first level subdirs
683  dir_unpicklers=[]
684  n_unpicklers=0
685  for sample_pkl in sample_pkls:
686  dir_unpickler=unpickler(sample_pkl)
687  dir_unpickler.start()
688  n_unpicklers+=1
689  dir_unpicklers.append(dir_unpickler)
690  if n_unpicklers>=1: #pickleing is very expensive. Do not overload cpu
691  n_unpicklers=0
692  for dir_unpickler in dir_unpicklers:
693  dir_unpickler.join()
694 
695  dir_dict={}
696 
697  # create a fake global directory
698  global_dir=Directory("global","")
699  for dir_unpickler in dir_unpicklers:
700  dir_unpickler.join()
701  directory=dir_unpickler.directory
702  #directory.prune("Run summary")
703  #directory.calcStats()
704  global_dir.meta=directory.meta
705  dir_dict[dir_unpickler.filename.replace(".pkl","")]=directory
706  global_dir.subdirs.append(directory)
707 
708  global_dir.calcStats()
709 
710  directories_barchart=make_barchart_summary(dir_dict,'dir_chart',"DQM Directory")
711  categories_barchart=make_barchart_summary(dir_dict,'cat_chart','Category',aggregation_rules)
712 
713  page_html = get_page_header(additional_header=directories_barchart+categories_barchart)
714  rel1=""
715  rel2=""
716  try:
717  rel1,rel2=title.split("VS")
718  except:
719  rel1=global_dir.meta.release1.split("-")[0]
720  rel2=global_dir.meta.release2.split("-")[0]
721  global_dir.meta.release1=rel1
722  global_dir.meta.release2=rel2
723 
724  # union of all subdirs names
725  all_subdirs=[]
726  for directory in dir_dict.values():
727  for subdir_name in directory.get_subdirs_names():
728  all_subdirs.append(subdir_name)
729  all_subdirs=sorted(list(set(all_subdirs)))
730 
731  # Get The title
732  page_html+= '<div class="span-20">'+\
733  '<h2><a name="top" href="https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon">RelMon</a> Global Report: %s</h2>'%title+\
734  '</div>'+\
735  '<div class="span-1">'+\
736  '<h2><a href="%s">main...</a></h2>' %relmon_mainpage+\
737  '</div>'+\
738  '<hr>'
739  page_html+='<div class="span-24"><p></p></div>\n'*3
740 
741  # Get The summary section
742  page_html+= get_summary_section(global_dir,False)
743 
744  # Make the anchor sections
745  page_html+= '<div class="span-24">'
746  page_html+= '<div class="span-20 colborder"><h2 class="alt">Sections:</h2>'+\
747  '<ul>'+\
748  '<li><a href="#summary_barchart">Summary Barchart</a></li>'+\
749  '<li><a href="#categories">Categories</a></li>'+\
750  '<li><a href="#detailed_barchart">Detailed Barchart</a></li>'+\
751  '<li><a href="#summary_table">Summary Table</a></li>'+\
752  '<li><a href="#rank_summary">Ranks Summary</a></li>'+\
753  '<li><a href="#twiki_table">Twiki Table</a></li>'+\
754  '</ul>'+\
755  '</div><hr>'
756 
757 
758  # Make the CategoriesBar chart
759  page_html+='<div class="span-24"><h2 class="alt"><a name="summary_barchart">Summary Barchart</a></h2></div>'
760  page_html+='<div id="cat_chart"></div> <a href="#top">Top...</a><hr>'
761 
762  # Make the gauges per categories
763  page_html+=make_categories_summary(dir_dict,aggregation_rules)
764 
765  # Make the Directories chart
766  page_html+='<div class="span-24"><h2 class="alt"><a name="detailed_barchart">Detailed Barchart</a></h2></div>'
767  page_html+='<div id="dir_chart"></div> <a href="#top">Top...</a><hr>'
768 
769  # Barbarian vertical space. Suggestions are welcome
770  for i in xrange(2):
771  page_html+='<div class="span-24"><p></p></div>\n'
772 
773 
774  # Prepare the table
775  page_html+='<div class="span-24"><h2 class="alt"><a name="summary_table">Summary Table</a></h2></div>'
776 
777  for i in xrange(5):
778  page_html+='<div class="span-24"><p></p></div>\n'
779 
780  page_html+="""
781  <table border="1" >
782  <tr>
783  <td> </td>
784  """
785 
786  # First row with samples
787  page_html+="""
788  <td><div class="span-1"><p class="rotation" style="alt"><b>Summary</b></p></div></td>"""
789 
790  sorted_samples=sorted(dir_dict.keys())
791  for sample in sorted_samples:
792  sample_nick=sample
793  ## For runs: put only the number after the _
794  #if "_" in sample:
795  #run_number=sample.split("_")[-1]
796  #if (not run_number.isalpha()) and len(run_number)>=6:
797  #sample_nick=run_number
798 
799 
800  page_html+="""
801  <td><div class="span-1"><p class="rotation" style="">%s</p></div></td>"""%sample_nick
802  page_html+=" </tr>\n"
803 
804 
805  # FIRST ROW
806  # Now the summaries at the beginning of the table
807  page_html+="<tr>"
808  page_html+='<td style="background-color:white;"><div class="span-1">'
809 
810  page_html+='<b>Summary</b></div></td>'
811  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))
812  for sample in sorted_samples:
813  col=dir_dict[sample]
814  # check if the directory was a top one or not
815  summary_page_name=hash_name("RelMonSummary", hashing_flag)+".html"
816  if col.name!="":
817  summary_page_name=hash_name(col.name, hashing_flag)+".html"
818  img_link=col.get_summary_chart_ajax(55,55)
819  page_html+='<td style="background-color:white;"><div class="span-1">'
820  page_html+='<a href="%s/%s"><img src="%s" title="%s"></a></div></td>' %(sample,summary_page_name,img_link,get_pie_tooltip(col))
821  page_html+="</tr>"
822 
823  # Now the content
824  for subdir_name in all_subdirs:
825 
826  page_html+=' <tr>\n'
827  page_html+=' <td style="background-color:white;">%s</td>\n' %subdir_name
828 
829  row_summary=Directory("row_summary","")
830  sample_counter=0
831  n_samples=len(sorted_samples)
832 
833  for sample in sorted_samples:
834  subdirs_dict=directory.get_subdirs_dict()
835  directory=dir_dict[sample]
836  dir_is_there=subdirs_dict.has_key(subdir_name)
837  if dir_is_there:
838  row_summary.subdirs.append(subdirs_dict[subdir_name])
839 
840  # one first row for the summary!
841  row_summary.calcStats()
842  img_link=row_summary.get_summary_chart_ajax(55,55)
843  page_html+='<td style="background-color:white;"><div class="span-1">'
844  page_html+='<img src="%s" title="%s"></div></td>' %(img_link,get_pie_tooltip(row_summary))
845 
846  for sample in sorted_samples:
847  sample_counter+=1
848 
849  directory=dir_dict[sample]
850  subdirs_dict=directory.get_subdirs_dict()
851 
852  # Check if the directory is the top one
853  summary_page=join(sample,"%s.html"%(hash_name(subdir_name, hashing_flag)))
854  if directory.name!="":
855  # We did not run on the topdir
856  summary_page=join(sample,"%s_%s.html"%(directory.name,hash_name(subdir_name,hashing_flag)))
857  dir_is_there=subdirs_dict.has_key(subdir_name)
858 
859  img_link="https://chart.googleapis.com/chart?cht=p3&chco=C0C0C0&chs=50x50&chd=t:1"
860  img_tooltip="N/A"
861  if dir_is_there:
862  #row_summary.subdirs.append(subdirs_dict[subdir_name])
863  img_link=subdirs_dict[subdir_name].get_summary_chart_ajax(50,50)
864  img_tooltip=get_pie_tooltip(subdirs_dict[subdir_name])
865 
866  page_html+='<td style="background-color:white;"><div class="span-1">'
867  if dir_is_there:
868  page_html+='<a href="%s">'%(summary_page)
869  page_html+='<img src="%s" title="%s" height=50 width=50>' %(img_link,img_tooltip)
870  if dir_is_there:
871  page_html+='</a>'
872  page_html+='</div></td>'
873 
874  page_html+=" </tr>\n"
875 
876 
877 
878  page_html+='</table> <a href="#top">Top...</a><hr>'
879 
880  page_html+=get_rank_section(global_dir)
881 
882  page_html+=make_twiki_table(dir_dict,aggregation_rules_twiki)
883 
884  page_html+=get_page_footer()
885  return page_html
886 
887 
#-----------UPDATES------
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
void set(const std::string &name, int value)
set the flag, with a run-time name
def directories2html.make_twiki_table (   dir_dict,
  aggregation_rules 
)

Definition at line 587 of file directories2html.py.

References build_gauge(), get_aggr_pairs_info(), and split.

Referenced by make_summary_table().

588 def make_twiki_table(dir_dict,aggregation_rules):
589 
590  # decide the release
591  meta= dir_dict.items()[0][1].meta
592  releases=sorted([meta.release1,meta.release2])
593  latest_release=releases[1].split("-")[0]
594 
595 
596  aggr_pairs_info= get_aggr_pairs_info(dir_dict,aggregation_rules)
597 
598  # Now Let's build the HTML
599 
600  html= '<div class="span-20 colborder">'
601  html+='<h2 class="alt"><a name="twiki_table">Twiki snipppet for release managers</a></h2>'
602  html+='<div>| Release | Comparison |'
603  for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
604  html+=cat_name
605  html+=" | "
606  html+='</div>'
607 
608  html+='<div>| %s | %%ICON{arrowdot}%% | '%latest_release
609 
610  # Now add all the line with small gauges
611 
612  for cat_name,present_subdirs,total_weight,average_success_rate in aggr_pairs_info:
613  #print cat_name,present_subdirs,total_weight,average_success_rate
614  html+=build_gauge(average_success_rate,small=True,escaped=True)
615  html+=" | "
616 
617  html+='</div> <a href="#top">Top...</a>'
618  html+='<hr>'
619  return html+'</div>'
620 
621 #-------------------------------------------------------------------------------
double split
Definition: MVATrainer.cc:139
def directories2html.plot_size (   h = 250,
  w = 200 
)

Definition at line 43 of file directories2html.py.

Referenced by fairy_url(), and fairy_url_single().

43 
44 def plot_size(h=250,w=200):
45  return "w=%s;h=%s" %(h,w)

Variable Documentation

directories2html.theargv = sys.argv

Definition at line 20 of file directories2html.py.