CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CalibMuon/DTCalibration/python/Workflow/CmsswTask.py

Go to the documentation of this file.
00001 import os
00002 
00003 class CmsswTask:
00004     def __init__(self, dir, configs, psets=None):
00005         self.dir = dir  
00006         self.configs = configs
00007         self.psets = psets
00008         self.initTask()
00009   
00010     def initTask(self):
00011         if self.psets:
00012             if not os.path.exists(self.dir): os.makedirs(self.dir)
00013             for pset_name in self.configs:
00014                 pset = self.psets[pset_name]
00015                 open(self.dir + '/' + pset_name,'w').write(pset)
00016  
00017     def run(self):
00018         if not os.path.exists(self.dir): os.makedirs(self.dir)
00019         cwd = os.getcwd()
00020         for pset in self.configs:
00021             os.chdir(self.dir)
00022             if not os.path.exists(pset): raise RuntimeError,'%s not found in dir %s' % (pset,os.getcwd())
00023 
00024             cmd = 'cmsRun %s' % pset
00025             print "Running", cmd, "in dir", self.dir
00026             os.system(cmd)
00027             os.chdir(cwd)