5 import shutil, sys, os, re, glob, string
7 from optparse
import OptionParser
15 self.parser_.add_option(
"-c",
"--comments", dest=
"comments",
16 help=
"name of another release",
18 self.parser_.add_option(
"-f",
"--force", dest=
"force",
20 help=
"overwrites the local benchmark page.",
25 self.
date_ = os.popen(
'date' ).read()
29 (self.options_, self.args_) = self.parser_.parse_args()
35 if os.path.isdir( outputDir ):
36 print outputDir,
"already exists" 37 if self.options_.force ==
False:
38 print 'sorry... run the script with the -h option for more information' 41 print 'overwriting local output directory...' 43 os.makedirs( outputDir )
48 imgTemplate =
'<IMG src="%s" width="500" align="left" border="0"><br clear="ALL">' 50 captionsContents = open( captions )
51 for line
in captionsContents:
54 img = imgTemplate % os.path.basename(picfile)
55 images =
"%s<h3>%s:</h3>\n%s\n" % (images, caption, img)
60 print 'File %s does not exist. Did you generate the comparison plots?' % picfile
61 print 'Aborting the script.\n' 62 print 'Solution 1: run without the -m "" option, to run the compare.C macro' 63 print 'Solution 2: run with the -m "myMacro.C" option, to run another macro' 73 if( re.compile(
'^\s*$').
match(line) ):
76 p = re.compile(
'^\s*(\S+)\s*\"(.*)\"');
83 print 'bad caption format: "%s"' % line
88 self.
website_ =
'/afs/cern.ch/cms/Physics/particleflow/Validation/cms-project-pfvalidation/Releases' 89 self.
url_ =
'http://cern.ch/pfvalidation/Releases' 96 if( os.access(self.
website_, os.W_OK)==
False ):
97 print 'cannot write to the website. Please ask Colin to give you access.' 101 for bench
in glob.glob(self.
website_ +
'/' + pattern):
103 p = re.compile(
'^%s/(\S+)$' % self.
website_);
106 (release, benchName, extension) =
decodePath( m.group(1) )
112 print bcolors.OKGREEN + m.group(1) + bcolors.ENDC
114 if afs:
print ' ',bench.benchmarkOnWebSite( self )
115 if url:
print ' ',bench.benchmarkUrl( self )
120 find =
'find %s -type d' % self.
website_ 121 for dir
in os.popen( find ):
124 comp =
'%s/\S+/\S+/%s' % (self.
website_,
125 benchmark.fullName() )
130 comparisons.append(dir)
147 (release, benchName, extension) =
decodePath( arg )
159 if arg!=
None and arg.count(
'_'):
160 print 'sorry, as said many times, underscores are not allowed in the extension ;P' 169 if( extension !=
None ):
180 return '%s/%s' % ( website, self.
release_ )
183 return '%s/%s' % ( website, self.
fullName() )
192 return '%s/%s' % ( website.url_, self.
release_ )
196 return '%s/%s' % ( self.
releaseUrl( website ),
201 if( os.path.isdir( rel )==
False):
202 print 'creating release %s' % self.
release_ 215 url = comparison.comparisonUrl( website )
218 indexFile = open( index)
219 indexFileTmp = open( indexTmp,
'w')
220 for line
in indexFile:
221 p = re.compile(
'<h2>Comparisons:</h2>')
223 indexFileTmp.write(line)
225 link =
'<A href="%s">%s</A><BR>\n' % (url, url)
226 indexFileTmp.write(link)
227 shutil.move( indexTmp, index)
236 return '%s/%s' % ( self.benchmark_.benchmarkOnWebSite(website),
240 return '%s/%s' % ( self.benchmark_.benchmarkUrl(website),
244 print 'Submitting comparison:' 245 print ' from: ',self.
path_ 249 print 'comparison already exists' 251 print 'overwriting comparison on the website...' 253 print 'submission cancelled. run with -h for a solution.' 256 print 'comparison directory does not yet exist. creating it.' 259 if os.system( mkdir ):
260 print 'problem creating the output directory on the website. Aborting.' 262 cp =
'cp %s %s' % (self.
path_ +
'/*',
265 print 'problem copying the files to the website aborting' 268 print 'access your comparison here:' 275 p = re.compile(
'^(\S+)/([^\s_]+)_(\S+)');
279 benchmarkname = m.group(2)
280 extension = m.group(3)
281 return (release, benchmarkname, extension )
283 return (
None,
None,
None)
291 if os.path.isfile( file ) ==
False:
292 print '%s is not a file' % file
295 (fileroot, fileext) = os.path.splitext( file )
297 print '%s does not end with %s' % (file, ext)
307 return 'infoNotFound.html' 309 if os.path.isfile(file):
310 shutil.copy(file, outputDir)
311 return os.path.basename(file)
def readCaptions(self, captions)
def readCaption(self, line)
def setOutputDir(self, outputDir)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.