Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-03 02:26:44

0001 #!/usr/bin/env python3
0002 
0003 #this script runs cmsStage multiple times in the case where it failes for some reason
0004 
0005 from __future__ import print_function
0006 from builtins import range
0007 if __name__ == '__main__':
0008 
0009     import PhysicsTools.HeppyCore.utils.eostools as eostools
0010     eostools.setCAFPath()
0011 
0012     from cmsIO import *
0013     from cmsStage import *
0014 
0015     import sys, time
0016 
0017     #this taken from the main of cmsStage
0018     argv = sys.argv[1:]
0019     (args, debug, force ) = parseOpts( argv )
0020 
0021     if not os.path.isfile(args[0]):
0022         print(args[0], 'does not exist.')
0023         sys.exit(1)
0024     source = cmsFile( args[0], "rfio" )
0025     destination = cmsFile( args[1], "stageout" )
0026     checkArgs( source, destination, force )
0027 
0028     #find the destination LFN
0029     dest = args[1]
0030     if eostools.isDirectory(dest):
0031         dest = os.path.join(dest,os.path.basename(args[0]))
0032     
0033     sleep_lengths = [1,10,60,600,1800]
0034     return_code = 0
0035     for i in range(5):
0036 
0037         #sleep for a while before running
0038         time.sleep(sleep_lengths[i])
0039 
0040         try:
0041             #run cmsStage
0042             print('cmsStage %s [%d/5]' % (' '.join(argv) , i+1))
0043             main(argv)
0044 
0045         except SystemExit as e:
0046             print("cmsStage exited with code '%s'. Retrying... [%d/5]" % ( str(e), i+1 ))
0047             return_code = e.code
0048         
0049         #sleep again before checking
0050         time.sleep(3)
0051 
0052         if eostools.fileExists(dest) and eostools.isFile(dest):
0053             if source.size() == destination.size():
0054                 return_code = 0
0055                 break
0056 
0057     sys.exit(return_code)