improve traceback while processing config file
the filename of the executed config file has to be known to 'exec' for a meaningfull traceback Change-Id: I3403740dc9198ce5f64741fbb112cb908159c704 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31055 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -126,13 +126,15 @@ class Config(dict):
|
|||||||
self.modules.append(mod)
|
self.modules.append(mod)
|
||||||
|
|
||||||
|
|
||||||
def process_file(config_text):
|
def process_file(filename):
|
||||||
|
with open(filename, 'rb') as f:
|
||||||
|
config_text = f.read()
|
||||||
node = NodeCollector()
|
node = NodeCollector()
|
||||||
mods = Collector(Mod)
|
mods = Collector(Mod)
|
||||||
ns = {'Node': node.add, 'Mod': mods.add, 'Param': Param, 'Command': Param, 'Group': Group}
|
ns = {'Node': node.add, 'Mod': mods.add, 'Param': Param, 'Command': Param, 'Group': Group}
|
||||||
|
|
||||||
# pylint: disable=exec-used
|
# pylint: disable=exec-used
|
||||||
exec(config_text, ns)
|
exec(compile(config_text, filename, 'exec'), ns)
|
||||||
return Config(node, mods)
|
return Config(node, mods)
|
||||||
|
|
||||||
|
|
||||||
@ -175,9 +177,7 @@ def load_config(cfgfiles, log):
|
|||||||
for cfgfile in cfgfiles.split(','):
|
for cfgfile in cfgfiles.split(','):
|
||||||
filename = to_config_path(cfgfile, log)
|
filename = to_config_path(cfgfile, log)
|
||||||
log.debug('Parsing config file %s...', filename)
|
log.debug('Parsing config file %s...', filename)
|
||||||
with open(filename, 'rb') as f:
|
cfg = process_file(filename)
|
||||||
config_text = f.read()
|
|
||||||
cfg = process_file(config_text)
|
|
||||||
if config:
|
if config:
|
||||||
config.merge_modules(cfg)
|
config.merge_modules(cfg)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user