CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/Validation/RecoParticleFlow/Benchmarks/Tools/submit.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # to submit a benchmark webpage to the validation website
00003 # author: Colin
00004 
00005 import shutil, sys, os, valtools
00006 
00007 from optparse import OptionParser
00008 
00009 
00010     
00011 
00012 parser = OptionParser()
00013 parser.usage = "usage: %prog"
00014 
00015 parser.add_option("-e", "--extension", dest="extension",
00016                   help="adds an extension to the name of this benchmark",
00017                   default=None)
00018 
00019 parser.add_option("-f", "--force", dest="force",action="store_true",
00020                   help="force the submission. Be careful!",
00021                   default=False)
00022 
00023 
00024 (options,args) = parser.parse_args()
00025 
00026 
00027  
00028 if len(args)!=0:
00029     parser.print_help()
00030     sys.exit(1)
00031 
00032 
00033 website = valtools.website()
00034 bench = valtools.benchmark( options.extension ) 
00035 localBench = valtools.benchmark()
00036 print 'submitting  from local: ', localBench
00037 print '                    to: ', bench
00038 
00039 comparisons = website.listComparisons( bench )
00040 if len(comparisons)>0:
00041     print 'You are about to make the following list of comparison pages obsolete. These pages will thus be removed:' 
00042     print comparisons
00043 
00044     answer = None
00045     while answer != 'y' and answer != 'n':
00046         answer = raw_input('do you agree? [y/n]')
00047 
00048         if answer == 'n':
00049             sys.exit(0)
00050 
00051 # check that the user can write in the website
00052 website.writeAccess()
00053 bench.makeRelease( website )
00054 
00055 
00056 if bench.exists( website ) == True:
00057     if options.force == False:
00058         print 'please use the -e option to choose another extension'
00059         print '  e.g: submit.py -e Feb10'
00060         print 'or force it.'
00061         sys.exit(1)
00062     else:
00063         print 'overwriting...'
00064         shutil.rmtree(bench.benchmarkOnWebSite(website))
00065 
00066 
00067 # local benchmark. this one does not have an extension!
00068 
00069 shutil.copytree(localBench.fullName(), bench.benchmarkOnWebSite(website) )
00070 print 'done. Access your benchmark here:'
00071 print bench.benchmarkUrl( website )
00072     
00073 # removing comparisons
00074 # COMPARISONS COULD ALSO BE REDONE. 
00075 for comparison in comparisons:
00076     rm = 'rm -rf '+comparison
00077     os.system(rm)
00078