ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/ValidateCfg.py
Revision: 1.4
Committed: Wed Nov 26 19:55:54 2008 UTC (16 years, 5 months ago) by ewv
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_6_0_pre2, CRAB_2_6_0_pre1, CRAB_2_5_1, CRAB_2_5_1_pre4, CRAB_2_5_1_pre3, CRAB_2_5_1_pre2, CRAB_2_5_1_pre1, CRAB_2_5_0, CRAB_2_5_0_pre7, CRAB_2_5_0_pre6, CRAB_2_5_0_pre5, CRAB_2_5_0_pre4, CRAB_2_5_0_pre3, CRAB_2_5_0_pre2, CRAB_2_5_0_pre1, CRAB_2_4_4, CRAB_2_4_4_pre6, CRAB_2_4_4_pre5, CRAB_2_4_4_pre4, CRAB_2_4_4_pre3, CRAB_2_4_4_pre2, CRAB_2_4_4_pre1, CRAB_2_4_3, CRAB_2_4_3_pre8, CRAB_2_4_3_pre7, CRAB_2_4_3_pre6, CRAB_2_4_3_pre5
Changes since 1.3: +33 -24 lines
Log Message:
More explicit messages including pointer to EDM HN

File Contents

# User Rev Content
1 spiga 1.1 import imp, sys
2     import traceback
3 spiga 1.2 import common
4 spiga 1.1 from crab_exceptions import *
5     from crab_logger import Logger
6    
7    
8     class ValidateCfg:
9     def __init__(self, args):
10 spiga 1.2
11     self.pset = args.get('pset','0')
12 ewv 1.4 if self.pset == '0' or self.pset.upper() == 'NONE' :
13     msg = 'Error: No configuration file has been specified in your crab.cfg file.'
14 spiga 1.2 raise CrabException(msg)
15    
16 spiga 1.1 def run(self):
17 ewv 1.4
18 spiga 1.1 if self.pset.endswith('py'):
19 ewv 1.4 self.DumpPset()
20     else:
21 spiga 1.1 self.IncludePset()
22    
23 ewv 1.4 return
24    
25 spiga 1.2 def ImportFile( self ):
26 spiga 1.1 """
27     Read in Pset object
28     """
29 spiga 1.3 common.logger.message( "Importing file %s"%self.pset)
30 spiga 1.1 handle = open(self.pset, 'r')
31 spiga 1.2
32 ewv 1.4 try:
33 spiga 1.1 cfo = imp.load_source("pycfg", self.pset, handle)
34     cmsProcess = cfo.process
35     except Exception, ex:
36     goodcfg = False
37 ewv 1.4 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 spiga 1.1 raise CrabException( msg )
42     handle.close()
43 ewv 1.4 return cmsProcess
44 spiga 1.1
45 ewv 1.4 def DumpPset( self ):
46     """
47     """
48 spiga 1.2 cmsProcess = self.ImportFile()
49    
50     common.logger.message( 'Starting the dump.....' )
51 ewv 1.4 try:
52 spiga 1.1 cmsProcess.dumpPython()
53 ewv 1.4 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 spiga 1.1 raise CrabException( msg )
59 ewv 1.4 msg = "Python parsing succeeded. File is valid.\n"
60 spiga 1.1 common.logger.message( msg )
61    
62 ewv 1.4 def IncludePset(self):
63     """
64     """
65 spiga 1.1 from FWCore.ParameterSet.Config import include
66 spiga 1.2 common.logger.message( 'Starting include.....' )
67 spiga 1.1 try:
68     cfo = include(self.pset)
69     except Exception, ex:
70 ewv 1.4 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 spiga 1.1 raise CrabException(msg)
75 ewv 1.4 msg = "Python parsing succeeded. File is valid.\n"
76 spiga 1.1 common.logger.message( msg )
77    
78    
79     if __name__ == '__main__' :
80    
81     pset = sys.argv[1]
82 ewv 1.4 check = ValidateCfg({'pset':pset})
83     check.run()