3 from __future__
import print_function
8 import web_templates
as templates
9 from optparse
import OptionParser
10 from Validation.RecoTau.ValidationOptions_cff
import allowedOptions
12 __author__ =
"Mauro Verzetti (mauro.verzetti@cern.ch)" 13 __doc__ =
"""Script to update the web-page to show newly updated results. First upload the TauID directory in the proper location in $PastResults""" 15 parser = OptionParser(description=__doc__)
16 parser.add_option(
'--test',action=
"store_true", dest=
"test", default=
False, help=
"used to test/debug the script. The html file are written locally")
17 (options,crap) = parser.parse_args()
20 m = re.match(
r'^CMSSW_(?P<one>[0-9]+)_(?P<two>[0-9]+)_(?P<three>[0-9]+)(?:_pre(?P<four>[0-9]+))?',relName)
22 prev =
int(m.group(
'four'))
if m.group(
'four')
else 1000000
23 return (m.group(
'one'),m.group(
'two'),m.group(
'three'),prev)
27 webDir = os.environ[
'PastResults']
29 print(
'Run cmsenv and source UtilityCommands.(c)sh first!')
33 webDir_subdirs = [x
for x
in os.listdir( webDir )
if os.path.isdir(webDir+x)]
34 official_releases = sorted( [x
for x
in webDir_subdirs
if re.findall(
r'^CMSSW_[0-9]+_[0-9]+_[0-9]+(?:_pre[0-9]+)?$',x)], key=unpackRelease)
35 special_releases = sorted( [x
for x
in webDir_subdirs
if re.findall(
r'^CMSSW_[0-9]+_[0-9]+_[0-9]+',x)
and not x
in official_releases], key=unpackRelease)
36 custom_made = [d
for d
in webDir_subdirs
if not d
in official_releases
and not d
in special_releases]
39 official_releases_links =
''.
join([templates.create_main_list_element(d)
for d
in official_releases])
40 special_releases_links =
''.
join([templates.create_main_list_element(d)
for d
in special_releases])
41 custom_made_links =
''.
join([templates.create_main_list_element(d)
for d
in custom_made])
42 main_web_page = templates.main_page_template % (official_releases_links, special_releases_links, custom_made_links)
43 main_web_page_path = webDir+
'index.html' if not options.test
else 'index.html' 44 main_web_page_html = open(main_web_page_path,
'w')
45 main_web_page_html.write(main_web_page)
46 main_web_page_html.close()
48 for rel
in official_releases+special_releases:
49 tauid_dir = webDir+rel+
'/TauID/' 50 reldir = webDir+rel+
'/' 51 datasets = [x
for x
in os.listdir(tauid_dir)
if os.path.isdir(tauid_dir+x)
and not x ==
'Reference']
52 cfg_file = glob.glob(tauid_dir+
'*/Config/showtags.txt')[0]
if glob.glob(tauid_dir+
'*/Config/showtags.txt')
else None 53 config = open(cfg_file).
read()
if cfg_file
else 'NO CONFIGURATION AVAILABLE!' 55 for dataset
in datasets:
56 dname = dataset.split(
'_')[0]
57 if not dname
in allowedOptions[
'eventType']:
59 pics = [path.split(rel+
'/')[1]
for path
in glob.glob(tauid_dir+dataset+
'/*.png')]
60 roots = glob.glob(tauid_dir+dataset+
'/*.root')[0]
61 rootf = (roots).
split(rel+
'/')[1]
62 ref_file = (glob.glob(tauid_dir+
'Reference/*'+dname+
'.root')[0]).
split(rel+
'/')[1]
if glob.glob(tauid_dir+
'Reference/*'+dname+
'.root')
else None 63 source =
'TauID/'+dataset+
'/Config/DataSource_cff.py' if os.path.isfile(tauid_dir+dataset+
'/Config/DataSource_cff.py')
else None 64 dir_link =
'TauID/'+dataset+
'/' 65 data_html.append(templates.usual_validation_dataset_template(dname, rootf, ref_file, dir_link, pics, source) )
66 release_html_page = templates.usual_validation_template.substitute(THIS_RELEASE=rel,CONFIG=config,DATASETS=
''.
join(data_html) )
67 release_web_page_path = reldir+
'index.html' if not options.test
else 'index.html' 68 release_page_html = open(release_web_page_path,
'w')
69 release_page_html.write(release_html_page)
70 release_page_html.close()
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def unpackRelease(relName)
def split(sequence, size)
static std::string join(char **cmd)