CMS 3D CMS Logo

CmsswTask.py
Go to the documentation of this file.
1 import os
2 
3 class CmsswTask:
4  def __init__(self, dir, configs, psets=None):
5  self.dir = dir
6  self.configs = configs
7  self.psets = psets
8  self.initTask()
9 
10  def initTask(self):
11  if self.psets:
12  if not os.path.exists(self.dir): os.makedirs(self.dir)
13  for pset_name in self.configs:
14  pset = self.psets[pset_name]
15  open(self.dir + '/' + pset_name,'w').write(pset)
16 
17  def run(self):
18  if not os.path.exists(self.dir): os.makedirs(self.dir)
19  cwd = os.getcwd()
20  for pset in self.configs:
21  os.chdir(self.dir)
22  if not os.path.exists(pset): raise RuntimeError('%s not found in dir %s' % (pset,os.getcwd()))
23 
24  cmd = 'cmsRun %s' % pset
25  print "Running", cmd, "in dir", self.dir
26  os.system(cmd)
27  os.chdir(cwd)
def initTask(self)
Definition: CmsswTask.py:10
def __init__(self, dir, configs, psets=None)
Definition: CmsswTask.py:4
def write(self, setup)