5 from __future__
import print_function
6 import shutil, sys, os, re, glob, string
8 from optparse
import OptionParser
16 self.parser_.add_option(
"-c",
"--comments", dest=
"comments",
17 help=
"name of another release",
19 self.parser_.add_option(
"-f",
"--force", dest=
"force",
21 help=
"overwrites the local benchmark page.",
26 self.
date_ = os.popen(
'date' ).read()
30 (self.options_, self.args_) = self.parser_.parse_args()
36 if os.path.isdir( outputDir ):
37 print(outputDir,
"already exists")
38 if self.options_.force ==
False:
39 print(
'sorry... run the script with the -h option for more information')
42 print(
'overwriting local output directory...')
44 os.makedirs( outputDir )
49 imgTemplate =
'<IMG src="%s" width="500" align="left" border="0"><br clear="ALL">' 51 captionsContents = open( captions )
52 for line
in captionsContents:
55 img = imgTemplate % os.path.basename(picfile)
56 images =
"%s<h3>%s:</h3>\n%s\n" % (images, caption, img)
61 print(
'File %s does not exist. Did you generate the comparison plots?' % picfile)
62 print(
'Aborting the script.\n')
63 print(
'Solution 1: run without the -m "" option, to run the compare.C macro')
64 print(
'Solution 2: run with the -m "myMacro.C" option, to run another macro')
74 if( re.compile(
'^\s*$').
match(line) ):
77 p = re.compile(
'^\s*(\S+)\s*\"(.*)\"');
84 print(
'bad caption format: "%s"' % line)
89 self.
website_ =
'/afs/cern.ch/cms/Physics/particleflow/Validation/cms-project-pfvalidation/Releases' 90 self.
url_ =
'http://cern.ch/pfvalidation/Releases' 97 if( os.access(self.
website_, os.W_OK)==
False ):
98 print(
'cannot write to the website. Please ask Colin to give you access.')
102 for bench
in glob.glob(self.
website_ +
'/' + pattern):
104 p = re.compile(
'^%s/(\S+)$' % self.
website_);
107 (release, benchName, extension) =
decodePath( m.group(1) )
113 print(bcolors.OKGREEN + m.group(1) + bcolors.ENDC)
115 if afs:
print(
' ',bench.benchmarkOnWebSite( self ))
116 if url:
print(
' ',bench.benchmarkUrl( self ))
121 find =
'find %s -type d' % self.
website_ 122 for dir
in os.popen( find ):
125 comp =
'%s/\S+/\S+/%s' % (self.
website_,
126 benchmark.fullName() )
131 comparisons.append(dir)
148 (release, benchName, extension) =
decodePath( arg )
160 if arg!=
None and arg.count(
'_'):
161 print(
'sorry, as said many times, underscores are not allowed in the extension ;P')
170 if( extension !=
None ):
181 return '%s/%s' % ( website, self.
release_ )
184 return '%s/%s' % ( website, self.
fullName() )
193 return '%s/%s' % ( website.url_, self.
release_ )
197 return '%s/%s' % ( self.
releaseUrl( website ),
202 if( os.path.isdir( rel )==
False):
216 url = comparison.comparisonUrl( website )
219 indexFile = open( index)
220 indexFileTmp = open( indexTmp,
'w')
221 for line
in indexFile:
222 p = re.compile(
'<h2>Comparisons:</h2>')
224 indexFileTmp.write(line)
226 link =
'<A href="%s">%s</A><BR>\n' % (url, url)
227 indexFileTmp.write(link)
228 shutil.move( indexTmp, index)
237 return '%s/%s' % ( self.benchmark_.benchmarkOnWebSite(website),
241 return '%s/%s' % ( self.benchmark_.benchmarkUrl(website),
245 print(
'Submitting comparison:')
250 print(
'comparison already exists')
252 print(
'overwriting comparison on the website...')
254 print(
'submission cancelled. run with -h for a solution.')
257 print(
'comparison directory does not yet exist. creating it.')
260 if os.system( mkdir ):
261 print(
'problem creating the output directory on the website. Aborting.')
263 cp =
'cp %s %s' % (self.
path_ +
'/*',
266 print(
'problem copying the files to the website aborting')
269 print(
'access your comparison here:')
276 p = re.compile(
'^(\S+)/([^\s_]+)_(\S+)');
280 benchmarkname = m.group(2)
281 extension = m.group(3)
282 return (release, benchmarkname, extension )
284 return (
None,
None,
None)
292 if os.path.isfile( file ) ==
False:
293 print(
'%s is not a file' % file)
296 (fileroot, fileext) = os.path.splitext( file )
298 print(
'%s does not end with %s' % (file, ext))
308 return 'infoNotFound.html' 310 if os.path.isfile(file):
311 shutil.copy(file, outputDir)
312 return os.path.basename(file)
S & print(S &os, JobReport::InputFile const &f)
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.