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 |
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 |