1 |
|
import imp, sys |
2 |
|
import traceback |
3 |
+ |
import common |
4 |
|
from crab_exceptions import * |
5 |
|
from crab_logger import Logger |
6 |
|
|
7 |
|
|
8 |
|
class ValidateCfg: |
9 |
|
def __init__(self, args): |
10 |
< |
|
11 |
< |
self.pset = args['CMSSW.pset'] |
12 |
< |
|
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.' |
14 |
> |
raise CrabException(msg) |
15 |
> |
|
16 |
|
def run(self): |
17 |
|
|
18 |
|
if self.pset.endswith('py'): |
22 |
|
|
23 |
|
return |
24 |
|
|
25 |
< |
def ImportFile(self): |
25 |
> |
def ImportFile( self ): |
26 |
|
""" |
27 |
|
Read in Pset object |
28 |
|
""" |
29 |
< |
common.logger.message( "Importing .py file %s"%fileName) |
29 |
> |
common.logger.message( "Importing .py file %s"%self.pset) |
30 |
|
handle = open(self.pset, 'r') |
31 |
+ |
|
32 |
|
try: |
33 |
|
cfo = imp.load_source("pycfg", self.pset, handle) |
34 |
|
cmsProcess = cfo.process |
39 |
|
handle.close() |
40 |
|
return cmsProcess |
41 |
|
|
42 |
< |
def DumpPset(self, cmsProcess ): |
42 |
> |
def DumpPset( self ): |
43 |
|
""" |
44 |
|
""" |
45 |
< |
common.logger.message( 'Starting the dump.....\n' ) |
45 |
> |
cmsProcess = self.ImportFile() |
46 |
> |
|
47 |
> |
common.logger.message( 'Starting the dump.....' ) |
48 |
|
try: |
49 |
|
cmsProcess.dumpPython() |
50 |
|
except Exception, ex: |
51 |
|
msg = "....dumpPython failed : \n\t%s" % str(traceback.format_exc()) |
52 |
|
raise CrabException( msg ) |
53 |
< |
msg = "....dumpPython succeded" |
53 |
> |
msg = "....dumpPython succeded\n" |
54 |
|
common.logger.message( msg ) |
55 |
|
|
56 |
|
def IncludePset(self): |
57 |
|
""" |
58 |
|
""" |
59 |
|
from FWCore.ParameterSet.Config import include |
60 |
< |
common.logger.message( 'Starting include.....\n' ) |
60 |
> |
common.logger.message( 'Starting include.....' ) |
61 |
|
try: |
62 |
|
cfo = include(self.pset) |
63 |
|
except Exception, ex: |
64 |
|
msg = '....include failed with error: \n\t %s'%str(traceback.format_exc()) |
65 |
|
raise CrabException(msg) |
66 |
< |
msg = "....include succeded" |
66 |
> |
msg = "....include succeded\n" |
67 |
|
common.logger.message( msg ) |
68 |
|
|
69 |
|
|