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

Comparing COMP/CRAB/python/ValidateCfg.py (file contents):
Revision 1.3 by spiga, Sun Nov 23 18:30:10 2008 UTC vs.
Revision 1.4 by ewv, Wed Nov 26 19:55:54 2008 UTC

# Line 9 | Line 9 | class ValidateCfg:
9      def __init__(self, args):
10  
11          self.pset = args.get('pset','0')
12 <        if self.pset == '0' or self.pset.upper() == 'NONE' :
13 <            msg = 'Error: Any configuration file has been specified.'
12 >        if self.pset == '0' or self.pset.upper() == 'NONE' :
13 >            msg = 'Error: No configuration file has been specified in your crab.cfg file.'
14              raise CrabException(msg)
15  
16      def run(self):
17 <          
17 >
18          if self.pset.endswith('py'):
19 <            self.DumpPset()  
20 <        else:  
19 >            self.DumpPset()
20 >        else:
21              self.IncludePset()
22  
23 <        return        
24 <  
23 >        return
24 >
25      def ImportFile( self ):
26          """
27          Read in Pset object
# Line 29 | Line 29 | class ValidateCfg:
29          common.logger.message( "Importing file %s"%self.pset)
30          handle = open(self.pset, 'r')
31  
32 <        try:    
32 >        try:
33              cfo = imp.load_source("pycfg", self.pset, handle)
34              cmsProcess = cfo.process
35          except Exception, ex:
36              goodcfg = False
37 <            msg = "%s file is not valid python: %s" % (self.pset,str(ex))
37 >            msg = "%s file is not valid python: %s" % \
38 >                (self.pset,str(traceback.format_exc()))
39 >            msg += "\n\nPlease post on the EDM hypernews if this " + \
40 >                   "information doesn't help solve this problem."
41              raise CrabException( msg )
42          handle.close()
43 <        return cmsProcess  
43 >        return cmsProcess
44  
45 <    def DumpPset( self ):        
46 <        """
47 <        """
45 >    def DumpPset( self ):
46 >        """
47 >        """
48          cmsProcess = self.ImportFile()
49  
50          common.logger.message( 'Starting the dump.....' )
51 <        try:      
51 >        try:
52              cmsProcess.dumpPython()
53 <        except Exception, ex:      
54 <            msg = "....dumpPython failed : \n\t%s" % str(traceback.format_exc())
53 >        except Exception, ex:
54 >            msg = "Python parsing failed: \n\n%s" % \
55 >                str(traceback.format_exc())
56 >            msg += "\n\nPlease post on the EDM hypernews if this " + \
57 >                   "information doesn't help solve this problem."
58              raise CrabException( msg )
59 <        msg = "....dumpPython succeded\n"
59 >        msg = "Python parsing succeeded. File is valid.\n"
60          common.logger.message( msg )
61  
62 <    def IncludePset(self):    
63 <        """
64 <        """
62 >    def IncludePset(self):
63 >        """
64 >        """
65          from FWCore.ParameterSet.Config import include
66          common.logger.message( 'Starting include.....' )
67          try:
68              cfo = include(self.pset)
69          except Exception, ex:
70 <            msg = '....include failed with error: \n\t %s'%str(traceback.format_exc())  
70 >            msg = "Python parsing failed: \n\n%s" % \
71 >                str(traceback.format_exc())
72 >            msg += "\n\nPlease post on the EDM hypernews if this " + \
73 >                   "information doesn't help solve this problem."
74              raise CrabException(msg)
75 <        msg = "....include succeded\n"
75 >        msg = "Python parsing succeeded. File is valid.\n"
76          common.logger.message( msg )
77  
78  
79   if __name__ == '__main__' :
80  
81      pset = sys.argv[1]
82 <    check = CheckPset(pset)
83 <    check.Dump()
82 >    check = ValidateCfg({'pset':pset})
83 >    check.run()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines