CMS 3D CMS Logo

Functions
tools Namespace Reference

Functions

def addCrabInputFile (crabCfg, inputFile)
 
def copyFilesFromCastor (castor_dir, output_dir, type='root')
 
def copyFilesLocal (dir, output_dir, type='root')
 
def create_single_iov_db (inputs, run_number, output_db)
 
def dqmWorkflowName (datasetpath, type, rev=1)
 
def get_iovs (db, tag)
 
def get_process_object (cfg)
 
def get_tags (global_tag, records)
 
def getDatasetStr (datasetpath)
 
def haddInCastor (castor_dir, result_file, type='root', prefix='rfio:', suffix=None)
 
def haddLocal (dir, result_file, type='root')
 
def listFilesInCastor (castor_dir, type='root', prefix='rfio:')
 
def listFilesLocal (dir, type='root')
 
def loadCmsProcess (psetPath)
 
def loadCmsProcessFile (psetName)
 
def loadCrabCfg (cfgName=None)
 
def loadCrabDefault (crabCfg, config)
 
def make_unique_runranges (ali_producer)
 
def parseInput (inputFields, requiredFields=())
 
def prependPaths (process, seqname)
 
def replaceTemplate (template, opts)
 
def run_checked (cmd, suppress_stderr=False)
 
def setGridEnv (cmssw_dir)
 
def writeCfg (process, dir, psetName)
 
def writeCfgPkl (process, dir, psetName)
 

Function Documentation

def tools.addCrabInputFile (   crabCfg,
  inputFile 
)

Definition at line 183 of file tools.py.

Referenced by DTDQMValidation.DTDQMValidation.initCrab(), DTAnalysisResiduals.DTAnalysisResiduals.initCrab(), DTTTrigValid.DTTTrigValid.initCrab(), DTResidualCalibration.DTResidualCalibration.initCrab(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initCrab(), and DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initCrab().

183 def addCrabInputFile(crabCfg,inputFile):
184  additionalInputFiles = ''
185  if crabCfg.has_option('USER','additional_input_files'):
186  additionalInputFiles = crabCfg.get('USER','additional_input_files')
187 
188  if additionalInputFiles: additionalInputFiles += ',%s' % inputFile
189  else: additionalInputFiles = inputFile
190 
191  crabCfg.set('USER','additional_input_files',additionalInputFiles)
192 
193  return crabCfg
194 
def addCrabInputFile(crabCfg, inputFile)
Definition: tools.py:183
def tools.copyFilesFromCastor (   castor_dir,
  output_dir,
  type = 'root' 
)

Definition at line 55 of file tools.py.

References listFilesInCastor().

Referenced by DTCalibrationWorker.DTCalibrationWorker.runNoiseWorkflow().

55 def copyFilesFromCastor(castor_dir,output_dir,type='root'):
56  from subprocess import call
57  files = listFilesInCastor(castor_dir,type,'')
58 
59  print "Copying files from %s to %s" % (castor_dir,output_dir)
60  for item in files:
61  cmd = ['rfcp',item,output_dir]
62  print "..." + item
63  retcode = call(cmd)
64  if retcode != 0: raise RuntimeError('Error in copying file %s to directory %s' % (item,output_dir))
65 
66  return 0
67 
def listFilesInCastor(castor_dir, type='root', prefix='rfio:')
Definition: tools.py:30
def copyFilesFromCastor(castor_dir, output_dir, type='root')
Definition: tools.py:55
def tools.copyFilesLocal (   dir,
  output_dir,
  type = 'root' 
)

Definition at line 68 of file tools.py.

References listFilesLocal().

Referenced by DTCalibrationWorker.DTCalibrationWorker.runNoiseWorkflow().

68 def copyFilesLocal(dir,output_dir,type='root'):
69  if not dir: raise ValueError('Please specify valid dir')
70  if not output_dir: raise ValueError('Please specify valid output dir')
71 
72  from subprocess import call
73  files = listFilesLocal(dir,type)
74  cmd = ['cp']
75  cmd.extend(files)
76  cmd.append(output_dir)
77  print cmd
78  retcode = call(cmd)
79  return retcode
80 
def copyFilesLocal(dir, output_dir, type='root')
Definition: tools.py:68
def listFilesLocal(dir, type='root')
Definition: tools.py:42
def tools.create_single_iov_db (   inputs,
  run_number,
  output_db 
)
Create an sqlite file with single-IOV tags for alignment payloads.

Arguments:
- `inputs`: dictionary with input needed for payload extraction
- `run_number`: run for which the IOVs are selected
- `output_db`: name of the output sqlite file

Definition at line 9 of file tools.py.

References join(), run_checked(), and harvestTrackValidationPlots.str.

9 def create_single_iov_db(inputs, run_number, output_db):
10  """Create an sqlite file with single-IOV tags for alignment payloads.
11 
12  Arguments:
13  - `inputs`: dictionary with input needed for payload extraction
14  - `run_number`: run for which the IOVs are selected
15  - `output_db`: name of the output sqlite file
16  """
17 
18  # find the IOV containing `run_number`
19  for record,tag in inputs.iteritems():
20  run_is_covered = False
21  for iov in reversed(tag["iovs"]):
22  if iov <= run_number:
23  tag["since"] = str(iov)
24  run_is_covered = True
25  break
26  if not run_is_covered:
27  msg = ("Run number {0:d} is not covered in '{1:s}' ({2:s}) from"
28  " '{3:s}'.".format(run_number, tag["tag"], record,
29  global_tag))
30  print msg
31  print "Aborting..."
32  sys.exit(1)
33 
34  result = {}
35  if os.path.exists(output_db): os.remove(output_db)
36  for record,tag in inputs.iteritems():
37  result[record] = {"connect": "sqlite_file:"+output_db,
38  "tag": "_".join([tag["tag"], tag["since"]])}
39 
40  if tag["connect"] == "pro":
41  source_connect = "frontier://FrontierProd/CMS_CONDITIONS"
42  elif tag["connect"] == "dev":
43  source_connect = "frontier://FrontierPrep/CMS_CONDITIONS"
44  else:
45  source_connect = tag["connect"]
46 
47  cmd = ("conddb_import",
48  "-f", source_connect,
49  "-c", result[record]["connect"],
50  "-i", tag["tag"],
51  "-t", result[record]["tag"],
52  "-b", str(run_number),
53  "-e", str(run_number))
54  run_checked(cmd)
55  if len(inputs) > 0:
56  run_checked(["sqlite3", output_db, "update iov set since=1"])
57 
58  return result
59 
60 
def create_single_iov_db(inputs, run_number, output_db)
Definition: tools.py:9
def run_checked(cmd, suppress_stderr=False)
Definition: tools.py:61
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def tools.dqmWorkflowName (   datasetpath,
  type,
  rev = 1 
)

Definition at line 23 of file tools.py.

Referenced by DTDqm.DTDqm.initProcess(), and DTDQMHarvesting.DTDQMHarvesting.initProcess().

23 def dqmWorkflowName(datasetpath,type,rev=1):
24  workflowName = datasetpath
25  sections = workflowName.split('/')[1:]
26  workflowName = '/%s/%s-%s-rev%d/%s' % (sections[0],sections[1],type,rev,sections[2])
27 
28  return workflowName
29 
def dqmWorkflowName(datasetpath, type, rev=1)
Definition: tools.py:23
def tools.get_iovs (   db,
  tag 
)
Retrieve the list of IOVs from `db` for `tag`.

Arguments:
- `db`: database connection string
- `tag`: tag of database record

Definition at line 161 of file tools.py.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor.all(), ALCARECOTkAlBeamHalo_cff.filter, createfilelist.int, and python.rootplot.root2matplotlib.replace().

161 def get_iovs(db, tag):
162  """Retrieve the list of IOVs from `db` for `tag`.
163 
164  Arguments:
165  - `db`: database connection string
166  - `tag`: tag of database record
167  """
168 
169  db = db.replace("sqlite_file:", "").replace("sqlite:", "")
170  db = db.replace("frontier://FrontierProd/CMS_CONDITIONS", "pro")
171  db = db.replace("frontier://FrontierPrep/CMS_CONDITIONS", "dev")
172 
173  con = conddb.connect(url = conddb.make_url(db))
174  session = con.session()
175  IOV = session.get_dbtype(conddb.IOV)
176 
177  iovs = set(session.query(IOV.since).filter(IOV.tag_name == tag).all())
178  if len(iovs) == 0:
179  print "No IOVs found for tag '"+tag+"' in database '"+db+"'."
180  sys.exit(1)
181 
182  session.close()
183 
184  return sorted([int(item[0]) for item in iovs])
def tools.get_process_object (   cfg)
Returns cms.Process object defined in `cfg`.

Arguments:
- `cfg`: path to CMSSW config file

Definition at line 81 of file tools.py.

82  """Returns cms.Process object defined in `cfg`.
83 
84  Arguments:
85  - `cfg`: path to CMSSW config file
86  """
87 
88  sys.path.append(os.path.dirname(cfg)) # add location to python path
89  cache_stdout = sys.stdout
90  sys.stdout = open(os.devnull, "w") # suppress unwanted output
91  try:
92  __configuration = \
93  importlib.import_module(os.path.splitext(os.path.basename(cfg))[0])
94  except Exception as e:
95  print "Problem detected in configuration file '{0}'.".format(cfg)
96  raise e
97  sys.stdout = cache_stdout
98  sys.path.pop() # clean up python path again
99  try:
100  os.remove(cfg+"c") # try to remove temporary .pyc file
101  except OSError as e:
102  if e.args == (2, "No such file or directory"): pass
103  else: raise
104 
105  return __configuration.process
106 
107 
def get_process_object(cfg)
Definition: tools.py:81
def tools.get_tags (   global_tag,
  records 
)
Get tags for `records` contained in `global_tag`.

Arguments:
- `global_tag`: global tag of interest
- `records`: database records of interest

Definition at line 126 of file tools.py.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor.all(), and ALCARECOTkAlBeamHalo_cff.filter.

126 def get_tags(global_tag, records):
127  """Get tags for `records` contained in `global_tag`.
128 
129  Arguments:
130  - `global_tag`: global tag of interest
131  - `records`: database records of interest
132  """
133 
134  if len(records) == 0: return {} # avoid useless DB query
135 
136  # check for auto GT
137  if global_tag.startswith("auto:"):
138  import Configuration.AlCa.autoCond as AC
139  try:
140  global_tag = AC.autoCond[global_tag.split("auto:")[-1]]
141  except KeyError:
142  print "Unsupported auto GT:", global_tag
143  sys.exit(1)
144 
145  # setting up the DB session
146  con = conddb.connect(url = conddb.make_url())
147  session = con.session()
148  GlobalTagMap = session.get_dbtype(conddb.GlobalTagMap)
149 
150  # query tag names for records of interest contained in `global_tag`
151  tags = session.query(GlobalTagMap.record, GlobalTagMap.tag_name).\
152  filter(GlobalTagMap.global_tag_name == global_tag,
153  GlobalTagMap.record.in_(records)).all()
154 
155  # closing the DB session
156  session.close()
157 
158  return {item[0]: {"tag": item[1], "connect": "pro"} for item in tags}
159 
160 
def get_tags(global_tag, records)
Definition: tools.py:126
def tools.haddInCastor (   castor_dir,
  result_file,
  type = 'root',
  prefix = 'rfio:',
  suffix = None 
)

Definition at line 81 of file tools.py.

References listFilesInCastor().

Referenced by DTCalibrationWorker.DTCalibrationWorker.runAnalysisResiduals(), DTCalibrationWorker.DTCalibrationWorker.runResidualCalib(), DTCalibrationWorker.DTCalibrationWorker.runTtrigProd(), DTCalibrationWorker.DTCalibrationWorker.runVDriftMeanTimerCalib(), and DTCalibrationWorker.DTCalibrationWorker.runVDriftSegmentCalib().

81 def haddInCastor(castor_dir,result_file,type = 'root',prefix = 'rfio:',suffix = None):
82  if not castor_dir: raise ValueError('Please specify valid castor dir')
83  if not result_file: raise ValueError('Please specify valid output file name')
84 
85  #cmd = 'hadd %s `./listfilesCastor %s | grep %s`'%(result_file,castor_dir,type)
86  #print "Running",cmd
87  #os.system(cmd)
88  from subprocess import call
89  files = listFilesInCastor(castor_dir,type,prefix)
90  if suffix: files = [item + suffix for item in files]
91 
92  cmd = ['hadd',result_file]
93  cmd.extend(files)
94  #print cmd
95  retcode = call(cmd)
96  return retcode
97 
def listFilesInCastor(castor_dir, type='root', prefix='rfio:')
Definition: tools.py:30
def haddInCastor(castor_dir, result_file, type='root', prefix='rfio:', suffix=None)
Definition: tools.py:81
def tools.haddLocal (   dir,
  result_file,
  type = 'root' 
)

Definition at line 98 of file tools.py.

References listFilesLocal().

Referenced by DTCalibrationWorker.DTCalibrationWorker.runAnalysisResiduals(), DTCalibrationWorker.DTCalibrationWorker.runResidualCalib(), DTCalibrationWorker.DTCalibrationWorker.runTtrigProd(), DTCalibrationWorker.DTCalibrationWorker.runVDriftMeanTimerCalib(), and DTCalibrationWorker.DTCalibrationWorker.runVDriftSegmentCalib().

98 def haddLocal(dir,result_file,type = 'root'):
99  if not dir: raise ValueError('Please specify valid dir')
100  if not result_file: raise ValueError('Please specify valid output file name')
101 
102  from subprocess import call
103  files = listFilesLocal(dir,type)
104  cmd = ['hadd',result_file]
105  cmd.extend(files)
106  #print cmd
107  retcode = call(cmd)
108  return retcode
109 
def haddLocal(dir, result_file, type='root')
Definition: tools.py:98
def listFilesLocal(dir, type='root')
Definition: tools.py:42
def tools.listFilesInCastor (   castor_dir,
  type = 'root',
  prefix = 'rfio:' 
)

Definition at line 30 of file tools.py.

Referenced by copyFilesFromCastor(), haddInCastor(), DTDqm.runDQM(), DTDQMMerge.runDQM(), DTCalibrationWorker.DTCalibrationWorker.runDQMClient(), DTCalibrationWorker.DTCalibrationWorker.runDQMHarvesting(), and DTCalibrationWorker.DTCalibrationWorker.runDQMMerge().

30 def listFilesInCastor(castor_dir,type = 'root',prefix = 'rfio:'):
31  if not castor_dir: raise ValueError('Please specify valid castor dir')
32 
33  from subprocess import Popen,PIPE
34  p1 = Popen(['nsls',castor_dir],stdout=PIPE)
35  #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE)
36  #files = [prefix + castor_dir + "/" + item[:-1] for item in p2.stdout]
37  #p2.stdout.close()
38  files = [ "%s%s/%s" % (prefix,castor_dir,item.rstrip()) for item in p1.stdout if item.find(type) != -1 ]
39  p1.stdout.close()
40  return files
41 
def listFilesInCastor(castor_dir, type='root', prefix='rfio:')
Definition: tools.py:30
def tools.listFilesLocal (   dir,
  type = 'root' 
)

Definition at line 42 of file tools.py.

Referenced by copyFilesLocal(), haddLocal(), DTCalibrationWorker.DTCalibrationWorker.runDQMClient(), DTCalibrationWorker.DTCalibrationWorker.runDQMHarvesting(), and DTCalibrationWorker.DTCalibrationWorker.runDQMMerge().

42 def listFilesLocal(dir,type = 'root'):
43  if not dir: raise ValueError('Please specify valid dir')
44 
45  #from subprocess import Popen,PIPE
46  #p1 = Popen(['ls',dir],stdout=PIPE)
47  #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE)
48  #files = [dir + "/" + item[:-1] for item in p2.stdout]
49  #p2.stdout.close()
50  files = os.listdir(dir)
51  files = [ "%s/%s" % (dir,item) for item in files if item.find(type) != -1 ]
52 
53  return files
54 
def listFilesLocal(dir, type='root')
Definition: tools.py:42
def tools.loadCmsProcessFile (   psetName)

Definition at line 140 of file tools.py.

140 def loadCmsProcessFile(psetName):
141  pset = imp.load_source("psetmodule",psetName)
142  return pset.process
143 
def loadCmsProcessFile(psetName)
Definition: tools.py:140
def tools.loadCrabDefault (   crabCfg,
  config 
)

Definition at line 195 of file tools.py.

Referenced by DTNoiseCalibration.DTNoiseCalibration.initCrab(), DTTTrigProd.DTTTrigProd.initCrab(), DTDQMValidation.DTDQMValidation.initCrab(), DTResidualCalibration.DTResidualCalibration.initCrab(), DTAnalysisResiduals.DTAnalysisResiduals.initCrab(), DTTTrigValid.DTTTrigValid.initCrab(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initCrab(), and DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initCrab().

195 def loadCrabDefault(crabCfg,config):
196  # CRAB section
197  if not crabCfg.has_section('CRAB'): crabCfg.add_section('CRAB')
198  crabCfg.set('CRAB','jobtype','cmssw')
199 
200  if hasattr(config,'scheduler') and config.scheduler: crabCfg.set('CRAB','scheduler',config.scheduler)
201  else: crabCfg.set('CRAB','scheduler','CAF')
202 
203  if hasattr(config,'useserver') and config.useserver: crabCfg.set('CRAB','use_server',1)
204 
205  # CMSSW section
206  if not crabCfg.has_section('CMSSW'): crabCfg.add_section('CMSSW')
207  if hasattr(config,'datasetpath') and config.datasetpath: crabCfg.set('CMSSW','datasetpath',config.datasetpath)
208  else: crabCfg.set('CMSSW','datasetpath','/XXX/YYY/ZZZ')
209  crabCfg.set('CMSSW','pset','pset.py')
210 
211  # Splitting config
212  crabCfg.remove_option('CMSSW','total_number_of_events')
213  crabCfg.remove_option('CMSSW','events_per_job')
214  crabCfg.remove_option('CMSSW','number_of_jobs')
215  crabCfg.remove_option('CMSSW','total_number_of_lumis')
216  crabCfg.remove_option('CMSSW','lumis_per_job')
217  crabCfg.remove_option('CMSSW','lumi_mask')
218  crabCfg.remove_option('CMSSW','split_by_run')
219 
220  """
221  if hasattr(config,'totalnumberevents'): crabCfg.set('CMSSW','total_number_of_events',config.totalnumberevents)
222  if hasattr(config,'eventsperjob'): crabCfg.set('CMSSW','events_per_job',config.eventsperjob)
223  """
224  if hasattr(config,'splitByLumi') and config.splitByLumi:
225  crabCfg.set('CMSSW','total_number_of_lumis',config.totalnumberlumis)
226  crabCfg.set('CMSSW','lumis_per_job',config.lumisperjob)
227  if hasattr(config,'lumimask') and config.lumimask: crabCfg.set('CMSSW','lumi_mask',config.lumimask)
228  elif hasattr(config,'splitByEvent') and config.splitByEvent:
229  crabCfg.set('CMSSW','total_number_of_events',config.totalnumberevents)
230  crabCfg.set('CMSSW','events_per_job',config.eventsperjob)
231  else:
232  crabCfg.set('CMSSW','split_by_run',1)
233 
234  if hasattr(config,'splitByEvent') and config.splitByEvent:
235  crabCfg.remove_option('CMSSW','runselection')
236  else:
237  if hasattr(config,'runselection') and config.runselection:
238  crabCfg.set('CMSSW','runselection',config.runselection)
239 
240  # USER section
241  if not crabCfg.has_section('USER'): crabCfg.add_section('USER')
242 
243  # Stageout config
244  if hasattr(config,'stageOutCAF') and config.stageOutCAF:
245  crabCfg.set('USER','return_data',0)
246  crabCfg.set('USER','copy_data',1)
247  crabCfg.set('USER','storage_element','T2_CH_CAF')
248  crabCfg.set('USER','user_remote_dir',config.userdircaf)
249  crabCfg.set('USER','check_user_remote_dir',0)
250  elif hasattr(config,'stageOutLocal') and config.stageOutLocal:
251  crabCfg.set('USER','return_data',1)
252  crabCfg.set('USER','copy_data',0)
253  crabCfg.remove_option('USER','storage_element')
254  crabCfg.remove_option('USER','user_remote_dir')
255  crabCfg.remove_option('USER','check_user_remote_dir')
256 
257  if hasattr(config,'email') and config.email: crabCfg.set('USER','eMail',config.email)
258  crabCfg.set('USER','xml_report','crabReport.xml')
259 
260  if hasattr(config,'runOnGrid') and config.runOnGrid:
261  crabCfg.remove_section('CAF')
262  if hasattr(config,'ce_black_list'):
263  if not crabCfg.has_section('GRID'): crabCfg.add_section('GRID')
264  crabCfg.set('GRID','ce_black_list', config.ce_black_list)
265  if hasattr(config,'ce_white_list'):
266  if not crabCfg.has_section('GRID'): crabCfg.add_section('GRID')
267  crabCfg.set('GRID','ce_white_list', config.ce_white_list)
268  else:
269  if not crabCfg.has_section('CAF'): crabCfg.add_section('CAF')
270  crabCfg.set('CAF','queue',config.queueAtCAF)
271 
272  return crabCfg
273 
def loadCrabDefault(crabCfg, config)
Definition: tools.py:195
def tools.make_unique_runranges (   ali_producer)
Derive unique run ranges from AlignmentProducer PSet.

Arguments:
- `ali_producer`: cms.PSet containing AlignmentProducer configuration

Definition at line 108 of file tools.py.

References createfilelist.int.

108 def make_unique_runranges(ali_producer):
109  """Derive unique run ranges from AlignmentProducer PSet.
110 
111  Arguments:
112  - `ali_producer`: cms.PSet containing AlignmentProducer configuration
113  """
114 
115  if (hasattr(ali_producer, "RunRangeSelection") and
116  len(ali_producer.RunRangeSelection) > 0):
117  iovs = set([int(iov)
118  for sel in ali_producer.RunRangeSelection
119  for iov in sel.RunRanges])
120  if len(iovs) == 0: return [1] # single IOV starting from run 1
121  return sorted(iovs)
122  else:
123  return [1] # single IOV starting from run 1
124 
125 
def make_unique_runranges(ali_producer)
Definition: tools.py:108
def tools.parseInput (   inputFields,
  requiredFields = () 
)

Definition at line 122 of file tools.py.

Referenced by edmStreamStallGrapher.readLogFile().

122 def parseInput(inputFields,requiredFields = ()):
123 
124  class options: pass
125  for item in sys.argv:
126  option = item.split('=')[0]
127  if option in inputFields:
128  value = item.split('=')[1]
129  if value in ('true','True','yes','Yes'): value = True
130  elif value in ('false','False','no','No'): value = False
131 
132  setattr(options,option,value)
133 
134  for item in requiredFields:
135  if not hasattr(options,item):
136  raise RuntimeError('Need to set "%s"' % item)
137 
138  return options
139 
def parseInput(inputFields, requiredFields=())
Definition: tools.py:122
def tools.replaceTemplate (   template,
  opts 
)

Definition at line 5 of file tools.py.

References harvestTrackValidationPlots.str.

5 def replaceTemplate(template,**opts):
6  result = open(template).read()
7  for item in opts:
8  old = '@@%s@@'%item
9  new = str(opts[item])
10  print "Replacing",old,"to",new
11  result = result.replace(old,new)
12 
13  return result
14 
def replaceTemplate(template, opts)
Definition: tools.py:5
def tools.run_checked (   cmd,
  suppress_stderr = False 
)
Run `cmd` and exit in case of failures.

Arguments:
- `cmd`: list containing the strings of the command
- `suppress_stderr`: suppress output from stderr

Definition at line 61 of file tools.py.

References join().

Referenced by create_single_iov_db().

61 def run_checked(cmd, suppress_stderr = False):
62  """Run `cmd` and exit in case of failures.
63 
64  Arguments:
65  - `cmd`: list containing the strings of the command
66  - `suppress_stderr`: suppress output from stderr
67  """
68 
69  try:
70  with open(os.devnull, "w") as devnull:
71  if suppress_stderr:
72  subprocess.check_call(cmd, stdout = devnull, stderr = devnull)
73  else:
74  subprocess.check_call(cmd, stdout = devnull)
75  except subprocess.CalledProcessError as e:
76  print "Problem in running the following command:"
77  print " ".join(e.cmd)
78  sys.exit(1)
79 
80 
def run_checked(cmd, suppress_stderr=False)
Definition: tools.py:61
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def tools.setGridEnv (   cmssw_dir)

Definition at line 110 of file tools.py.

110 def setGridEnv(cmssw_dir):
111  cwd = os.getcwd()
112  os.chdir(cmssw_dir)
113 
114  os.system('source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh')
115  os.system('cmsenv')
116  os.system('source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh')
117 
118  os.chdir(cwd)
119 
120  return
121 
def setGridEnv(cmssw_dir)
Definition: tools.py:110
def tools.writeCfg (   process,
  dir,
  psetName 
)

Definition at line 158 of file tools.py.

References TriggerAnalyzer.write().

158 def writeCfg(process,dir,psetName):
159  if not os.path.exists(dir): os.makedirs(dir)
160  open(dir + '/' + psetName,'w').write(process.dumpPython())
161 
def writeCfg(process, dir, psetName)
Definition: tools.py:158
def write(self, setup)
def tools.writeCfgPkl (   process,
  dir,
  psetName 
)

Definition at line 162 of file tools.py.

162 def writeCfgPkl(process,dir,psetName):
163  if not os.path.exists(dir): os.makedirs(dir)
164 
165  pklFileName = psetName.split('.')[0] + '.pkl'
166  pklFile = open(dir + '/' + pklFileName,"wb")
167  myPickle = pickle.Pickler(pklFile)
168  myPickle.dump(process)
169  pklFile.close()
170 
171  outFile = open(dir + '/' + psetName,"w")
172  outFile.write("import FWCore.ParameterSet.Config as cms\n")
173  outFile.write("import pickle\n")
174  outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName)
175  outFile.close()
176 
177 
def writeCfgPkl(process, dir, psetName)
Definition: tools.py:162