ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PsetManipulator.py
(Generate patch)

Comparing COMP/CRAB/python/PsetManipulator.py (file contents):
Revision 1.16 by ewv, Wed Apr 30 17:03:57 2008 UTC vs.
Revision 1.23 by slacapra, Thu Nov 6 17:51:43 2008 UTC

# Line 31 | Line 31 | class PsetManipulator:
31              try:   # Nested form for Python < 2.5
32                  try:
33                      self.cfo = imp.load_source("pycfg", self.pset, handle)
34 +                    self.cmsProcess = self.cfo.process
35                  except Exception, ex:
36                      msg = "Your config file is not valid python: %s" % str(ex)
37                      raise CrabException(msg)
38              finally:
39                  handle.close()
39            self.cfg = CfgInterface(self.cfo.process)
40          else:
41              try:
42                  self.cfo = include(self.pset)
43 <                self.cfg = CfgInterface(self.cfo)
43 >                self.cmsProcess = self.cfo
44              except Exception, ex:
45                  msg =  "Your cfg file is not valid, %s\n" % str(ex)
46 <                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/CrabFaq#Problem_with_ParameterSet_parsin\n"
46 >                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
47                  msg += "  may help you understand the problem."
48                  raise CrabException(msg)
49 +        self.cfg = CfgInterface(self.cmsProcess)
50  
51      def maxEvent(self, maxEv):
52          """
# Line 62 | Line 63 | class PsetManipulator:
63          # FUTURE: Can drop cfg mode for CMSSW < 2_1_x
64          outFile = open(common.work_space.jobDir()+name,"w")
65          if name.endswith('py'):
66 <          outFile.write("import FWCore.ParameterSet.Config as cms\n")
67 <          outFile.write(self.cfo.dumpPython())
66 >            outFile.write("import FWCore.ParameterSet.Config as cms\n")
67 >            try:
68 >                outFile.write(self.cmsProcess.dumpPython())
69 >            except Exception, ex:
70 >                msg =  "Your cfg file is not valid, %s\n" % str(ex)
71 >                msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#Problem_with_ParameterSet_parsin\n"
72 >                msg += "  may help you understand the problem."
73 >                raise CrabException(msg)
74 >
75          else:
76 <          outFile.write(str(self.cfg))
76 >            outFile.write(self.cfg.data.dumpConfig())
77          outFile.close()
78  
79          return
# Line 96 | Line 104 | class PsetManipulator:
104              messageLogger.fwkJobReports.append(name)
105  
106          return
107 +
108 +    def getTFileService(self):
109 +        """ Get Output filename from TFileService and return it. If not existing, return None """
110 +        if not self.cfg.data.services.has_key('TFileService'):
111 +            return None
112 +        tFileService = self.cfg.data.services['TFileService']
113 +        if "fileName" in tFileService.parameterNames_():
114 +            fileName = getattr(tFileService,'fileName',None).value()
115 +            return fileName
116 +        return None
117 +
118 +    def getPoolOutputModule(self):
119 +        """ Get Output filename from PoolOutputModule and return it. If not existing, return None """
120 +        if not self.cfg.data.outputModules:
121 +            return None
122 +        poolOutputModule = self.cfg.data.outputModules
123 +        for out in poolOutputModule:
124 +            return poolOutputModule[out].fileName.value()
125 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines