publish_reco_validation.py
Go to the documentation of this file.
1 #!/usr/bin/env python2
2 
3 # This script takes given root files, invokes the validation framework
4 # and publish websites.
5 # This script presupposes that the user defined her/his setup_nova function in
6 # ~/.bashrc. This can be made configurable if needed.
7 
8 from ConfigParser import *
9 import argparse, os
10 
11 def make_yaml():
12  with open('validation_config.yaml','w') as outf:
13  outf.write('{\n')
14  outf.write(' "validation_name": "'+validation_name+'",\n')
15  outf.write(' "histogram_topdirs": {\n')
16  for i in range(0, len(root_files)):
17  subdir_name = os.path.basename(root_files[i].rstrip('.root'))
18  outf.write(' "'+subdir_name+'": "'+root_files[i])
19  if i != len(root_files) - 1: outf.write('",\n')
20  else: outf.write('"\n')
21  outf.write(' },\n')
22  outf.write(' "output_dir": "'+output_dir+'"\n')
23  outf.write('}\n')
24 
25 #
26 # command line argument parsing
27 #
28 parser = argparse.ArgumentParser()
29 parser.add_argument('-c', '--config_file', type=str, help='configuration file name', default='publish_reco_validation.cfg')
30 parser.add_argument('--overwrite', dest='overwrite', help='overwrite output directory', action='store_true')
31 parser.add_argument('--no-overwrite', dest='overwrite', help='not overwrite output directory', action='store_false')
32 parser.set_defaults(overwrite=True)
33 parser.add_argument('--cleanup', dest='cleanup', help='remove the yaml file for framwork configuration', action='store_true')
34 parser.add_argument('--no-cleanup', dest='cleanup', help='keep the yaml file for framwork configuration', action='store_false')
35 parser.set_defaults(cleanup=True)
36 args = parser.parse_args()
37 config_file = args.config_file
38 overwrite = args.overwrite
39 cleanup = args.cleanup
40 
41 #
42 # read in the configuration file
43 #
44 parser = SafeConfigParser()
45 parser.read(config_file)
46 root_files = [x.strip() for x in parser.get('cernroot', 'filenames').split(',')]
47 output_dir = parser.get('output_dir', 'path')
48 validation_name = parser.get('validation_name', 'name')
49 # some preparation work...
50 project_dir = os.path.join(output_dir, validation_name.replace(' ', '\ '))
51 if overwrite: os.system('rm -rf '+project_dir)
52 if os.path.exists(os.path.join(output_dir, 'static_content')):
53  os.system('rm -rf '+os.path.join(output_dir, 'static_content'))
54 os.system('mkdir -p '+output_dir)
55 
56 #
57 # make the yaml configuration file for the framework to use
58 #
59 make_yaml()
60 
61 #
62 # Run the validation framewok. Generally the development version will do.
63 #
64 cmd = '. ~/.bashrc;setup_nova;sh $SRT_PUBLIC_CONTEXT/Validation/generic/run_validation.sh validation_config.yaml'
65 cmd += ';cp -r $SRT_PUBLIC_CONTEXT/Validation/generic/static_content '+output_dir
66 os.system(cmd)
67 if cleanup: os.system('rm -f validation_config.yaml')
68 print 'Webpages are published to:'
69 print output_dir.replace('/nusoft/app/web/htdoc','http://nusoft.fnal.gov')
void split(double tt, double *fr)
procfile open("FD_BRL_v0.txt")