Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-10 22:50:03

0001 #!/usr/bin/env python3
0002 
0003 ## This script writes an index.html page
0004 ## displaying all plots contained in the 
0005 ## directory.
0006 ##
0007 ## The file: makeWebpage.html is needed
0008 ## to be kept in the same place as the
0009 ## script and is used as a template.
0010 ## -------------------------------------
0011 ## Usage: ./makeWebpage.py DIR
0012 ## -------------------------------------
0013 ## with DIR = the path to the directoy
0014 ## containig the plots.
0015 ## DIR will also be the title of the
0016 ## webpage.
0017 ##
0018 ## For the moment it works for .gif's.
0019 ## For other formats, change line 42
0020 ## accordingly.
0021 ##
0022 ## After running the script, copy the
0023 ## folder conatining the plots and the
0024 ## index.html to an apropriate place.
0025 ## (This can be autmated too, if needed.)
0026 
0027 from __future__ import print_function
0028 import sys
0029 import os
0030 import re
0031 
0032 directory=sys.argv[1]
0033 oldV=sys.argv[2]
0034 newV=sys.argv[3]
0035 sample=sys.argv[4]
0036 
0037 # get the plots in the directory
0038 list = os.listdir(directory)
0039 
0040 # open a tmeplate file and the new .html file
0041 template=open("makeWebpage.html","r")
0042 page=open(directory+"/index.html","w")
0043 
0044 # write the common part of the index.html
0045 for line in template:
0046     if(re.search(r'blablabla',line)!=None):
0047         page.write(sys.argv[1])
0048     else:
0049         page.write(line)
0050 
0051 page.write('<h1> Track based conversions: '+sys.argv[3]+' vs '+sys.argv[2]+' Validation<br> Sample used: '+sys.argv[4]+ '<br><h3>In all plots below, '+sys.argv[2]+' is in purple, '+sys.argv[3]+' in black<br> Responsible: N. Marinelli</h3>')
0052 
0053 # add all the plots in the directory
0054 for i in range(len(list)):
0055     if(re.search(r'gif',list[i])!=None):
0056         print(list[i])
0057         page.write('<a href=" '+list[i])
0058         page.write('" onMouseOver="ThumbnailPlot(')
0059         page.write("'"+list[i]+"'), ClearNotes(),  ThumbnailNote() ")
0060         page.write('"> <img src="'+list[i]+' " style="height:22px; width:25px;"><small>'+list[i]+' </small></a> <br> \n')
0061 
0062 # write the last lines
0063 page.write('<br>\n')
0064 page.write('<div id="thumb_gen"><a href="#" id="thumblink_l"><img src="" id="thumb_l" width=0 height=0 border=0></a></div> \n')
0065 page.write('</body> \n')
0066 page.write(' </html>\n')
0067 
0068 
0069 # now copy everything on the wwweth server...
0070 #os.system("scp -r "+directory+" wwweth.cern.ch:JetMETPromptAnalysis/")
0071 
0072 
0073 
0074 
0075 
0076 
0077 
0078 
0079 
0080 
0081 
0082 
0083