Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:48:53

0001 #! /usr/bin/env python3
0002 
0003 # A Pyrelval Wrapper
0004 
0005 from __future__ import print_function
0006 def run():
0007         import sys
0008         import os
0009         import Configuration.Applications
0010         from Configuration.Applications.ConfigBuilder import ConfigBuilder
0011         from Configuration.Applications.cmsDriverOptions import OptionsFromCommandLine
0012         options = OptionsFromCommandLine()
0013         
0014         # after cleanup of all config parameters pass it to the ConfigBuilder
0015         configBuilder = ConfigBuilder(options, with_output = True, with_input = True)
0016 
0017         # Switch on any eras that have been specified. This is not required to create
0018         # the file, it is only relevant if dump_python is set. It does have to be done
0019         # before the prepare() call though. If not, then the config files will be loaded
0020         # without applying the era changes. This doesn't affect the config file written,
0021         # but when the dump_python branch uses execfile to read it back in it doesn't
0022         # reload the modules - it picks up a reference to the already loaded ones. 
0023         if hasattr( options, "era" ) and options.era is not None :
0024             from Configuration.StandardSequences.Eras import eras
0025             for eraName in options.era.split(',') :
0026                 getattr( eras, eraName )._setChosen()
0027         
0028         configBuilder.prepare()
0029         # fetch the results and write it to file
0030         config = open(options.python_filename,"w")
0031         config.write(configBuilder.pythonCfgCode)
0032         config.close()
0033 
0034         # handle different dump options
0035         if options.dump_python:
0036             status_code = os.system('edmConfigDump -o {f} {f}'.format(f=options.python_filename))
0037             if status_code: sys.exit(status_code)
0038             print("Expanded config file", options.python_filename, "created")
0039             sys.exit(0)           
0040   
0041         if options.no_exec_flag:
0042             print("Config file "+options.python_filename+ " created")
0043             sys.exit(0)
0044         else:
0045             commandString = options.prefix+" cmsRun "+options.suffix
0046             print("Starting "+commandString+' '+options.python_filename)
0047             commands = commandString.lstrip().split()
0048             sys.stdout.flush()
0049             os.execvpe(commands[0],commands+[options.python_filename],os.environ)
0050             sys.exit()
0051 
0052 run()