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.13 by ewv, Tue Nov 20 17:06:50 2007 UTC vs.
Revision 1.14 by ewv, Fri Dec 7 21:41:20 2007 UTC

# Line 2 | Line 2
2  
3   import os
4   import common
5 + import imp
6   from crab_util import *
7   from crab_exceptions import *
8   from crab_logger import Logger
# Line 24 | Line 25 | class PsetManipulator:
25          #convert Pset
26          from FWCore.ParameterSet.Config import include
27          common.logger.debug(3,"PsetManipulator::__init__: PSet file = "+self.pset)
28 <        self.cfo = include(self.pset)
29 <        self.cfg = CfgInterface(self.cfo)
30 <
28 >        if (self.pset.endswith('py') or self.pset.endswith('pycfg') ):
29 >          handle = open(self.pset, 'r')
30 >          try:   # Nested form for Python < 2.5
31 >            try:
32 >              self.cfo = imp.load_source("pycfg", self.pset, handle)
33 >            except Exception, ex:
34 >              msg = "Your pycfg file is not valid python: %s" % str(ex)
35 >              raise CrabException(msg)
36 >          finally:
37 >              handle.close()
38 >          self.cfg = CfgInterface(self.cfo.process)
39 >        else:
40 >          try:
41 >            self.cfo = include(self.pset)
42 >            self.cfg = CfgInterface(self.cfo)
43 >          except Exception, ex:
44 >            msg =  "Your cfg file is not valid, %s\n" % str(ex)
45 >            msg += "  https://twiki.cern.ch/twiki/bin/view/CMS/CrabFaq#Problem_with_ParameterSet_parsin\n"
46 >            msg += "  may help you understand the problem."
47 >            raise CrabException(msg)
48      def inputModule(self, source):
49          """
50          Set  vString Filenames key

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines