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