CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Validation/RecoParticleFlow/Benchmarks/Tools/indexGen.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 
00004 import shutil, sys, os, re, valtools
00005 
00006 from string import Template
00007 
00008 from optparse import OptionParser
00009 
00010 
00011 
00012 webpage = valtools.webpage()
00013 
00014 webpage.parser_.usage = "usage: %prog. Run from your Benchmark directory"
00015 webpage.parser_.add_option("-r", "--recipe", dest="recipe",
00016                            help="url pointing to a recipe",
00017                            default="None")
00018 webpage.parser_.add_option("-t", "--title", dest="title",
00019                            help="Benchmark title",
00020                            default="")
00021 webpage.parser_.add_option("-g", "--gensource", dest="pyGenSource",
00022                            help="python file for the CMSSW source of the generated events, which is used in input to your simulation and reconstruction process",
00023                            default="None")
00024 webpage.parser_.add_option("-s", "--simulation", dest="pySim",
00025                            help="python file for your CMSSW simulation and/or reconstruction process.",
00026                            default="None")
00027 webpage.parseArgs()
00028 
00029 
00030 if len(webpage.args_)!=0:
00031     webpage.parser_.print_help()
00032     sys.exit(1)
00033 
00034 benchmark = valtools.benchmark()
00035 
00036 webpage.setOutputDir( benchmark.fullName() )
00037 
00038 macro = 'plot.C'
00039 recipe = webpage.options_.recipe
00040 genConfig = webpage.options_.pyGenSource
00041 simConfig = webpage.options_.pySim
00042 benchmarkConfig = 'benchmark_cfg.py'
00043 
00044 # information about CMSSW
00045 cmssw = os.environ['CMSSW_VERSION']
00046 showTags = os.popen( 'showtags -t -r -u').read()
00047 
00048 title = webpage.benchmarkName_
00049 
00050 templateFile = 'index.html'
00051 
00052 outputDir = webpage.outputDir_
00053 indexhtml = "%s/%s" % (webpage.templates_,templateFile)
00054 
00055 
00056 valtools.testFileType(genConfig, ".py")
00057 valtools.testFileType(simConfig, ".py")
00058 valtools.testFileType(benchmarkConfig, ".py")
00059 valtools.testFileType(macro, ".C")
00060 
00061 valtools.testFileType(indexhtml, ".html")
00062 infonotfoundhtml = "%s/%s" % (webpage.templates_,"infoNotFound.html")
00063 valtools.testFileType(infonotfoundhtml, ".html")
00064 
00065 
00066 recipeLink = valtools.processFile( recipe, webpage.outputDir_ )
00067 genConfigLink = valtools.processFile(genConfig, webpage.outputDir_  )
00068 simConfigLink = valtools.processFile( simConfig, webpage.outputDir_ )
00069 benchmarkConfigLink = valtools.processFile( benchmarkConfig,
00070                                             webpage.outputDir_ )
00071 macroLink = valtools.processFile(macro, webpage.outputDir_  )
00072 rootFileLink = valtools.processFile(webpage.rootFile_, webpage.outputDir_  )
00073 
00074 comments = webpage.options_.comments
00075 images = webpage.readCaptions('captions.txt')
00076 
00077 ifile = open( indexhtml )
00078 indexTemplate = ifile.read()
00079 s = Template(indexTemplate)
00080 subst = s.substitute(title = title,
00081                      recipe = recipe,
00082                      recipeLink = recipeLink,
00083                      genConfig = os.path.basename(genConfig),
00084                      genConfigLink = genConfigLink,
00085                      simConfig = os.path.basename(simConfig),
00086                      simConfigLink = simConfigLink,
00087                      benchmarkConfig = os.path.basename(benchmarkConfig),
00088                      benchmarkConfigLink = benchmarkConfigLink,
00089                      macro =  os.path.basename(macro), 
00090                      macroLink = macroLink,
00091                      rootFile =  os.path.basename(webpage.rootFile_), 
00092                      rootFileLink =  rootFileLink, 
00093                      comments = comments,
00094                      cmssw = cmssw,
00095                      showTags = showTags,
00096                      images = images, 
00097                      username = os.environ['USER'],
00098                      date = webpage.date_
00099                      )
00100 
00101 ofile = open( '%s/index.html' % outputDir, 'w' )
00102 ofile.write( subst )
00103 
00104 ifile = open( infonotfoundhtml )
00105 infoNotFoundTemplate = ifile.read()
00106 s2 = Template(infoNotFoundTemplate)
00107 subst2 = s2.substitute( username = os.environ['USER'] )
00108 ofile2 = open( '%s/infoNotFound.html' % outputDir, 'w' )
00109 ofile2.write( subst2 )
00110 
00111 print 'webpage directory successfully created in', outputDir
00112