CMS 3D CMS Logo

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