test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cmsDriver.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # A Pyrelval Wrapper
4 
5 def run():
6  import sys
7  import os
8  import Configuration.Applications
9  from Configuration.Applications.ConfigBuilder import ConfigBuilder
10  from Configuration.Applications.cmsDriverOptions import OptionsFromCommandLine
11  options = OptionsFromCommandLine()
12 
13  # after cleanup of all config parameters pass it to the ConfigBuilder
14  configBuilder = ConfigBuilder(options, with_output = True, with_input = True)
15 
16  # Switch on any eras that have been specified. This is not required to create
17  # the file, it is only relevant if dump_python is set. It does have to be done
18  # before the prepare() call though. If not, then the config files will be loaded
19  # without applying the era changes. This doesn't affect the config file written,
20  # but when the dump_python branch uses execfile to read it back in it doesn't
21  # reload the modules - it picks up a reference to the already loaded ones.
22  if hasattr( options, "era" ) and options.era is not None :
23  from Configuration.StandardSequences.Eras import eras
24  for eraName in options.era.split(',') :
25  getattr( eras, eraName )._setChosen()
26 
27  configBuilder.prepare()
28  # fetch the results and write it to file
29  config = file(options.python_filename,"w")
30  config.write(configBuilder.pythonCfgCode)
31  config.close()
32 
33  # handle different dump options
34  if options.dump_python:
35  result = {}
36  execfile(options.python_filename, result)
37  process = result["process"]
38  expanded = process.dumpPython()
39  expandedFile = file(options.python_filename,"w")
40  expandedFile.write(expanded)
41  expandedFile.close()
42  print "Expanded config file", options.python_filename, "created"
43  sys.exit(0)
44 
45  if options.no_exec_flag:
46  print "Config file "+options.python_filename+ " created"
47  sys.exit(0)
48  else:
49  commandString = options.prefix+" cmsRun "+options.suffix
50  print "Starting "+commandString+' '+options.python_filename
51  commands = commandString.lstrip().split()
52  os.execvpe(commands[0],commands+[options.python_filename],os.environ)
53  sys.exit()
54 
55 run()
56 
57 
58 
def run
Definition: cmsDriver.py:5
double split
Definition: MVATrainer.cc:139