1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

ConfigParser: Added the ability to not wrap exception messages for ConfigParser

Both AgendaParser and ConfigParsers wrap exceptions with a a message
saying what source of configuration caused the exception. AgendaParser
uses ConfigParser within its load method, this leads to the "Error in foo"
message appearing twice. This lets AgendaParser turn of the wrapping
in ConfigParser
This commit is contained in:
Sebastian Goscik 2016-09-21 14:59:01 +01:00
parent e95ba608ec
commit 1bee34e6bc

View File

@ -167,7 +167,7 @@ class ConfigParser(object):
def load_from_path(self, filepath):
self.load(_load_file(filepath, "Config"), filepath)
def load(self, raw, source): # pylint: disable=too-many-branches
def load(self, raw, source, wrap_exceptions=True): # pylint: disable=too-many-branches
try:
if 'run_name' in raw:
msg = '"run_name" can only be specified in the config section of an agenda'
@ -201,7 +201,10 @@ class ConfigParser(object):
self.plugin_cache.add_configs(name, values, source)
except ConfigError as e:
raise ConfigError('Error in "{}":\n{}'.format(source, str(e)))
if wrap_exceptions:
raise ConfigError('Error in "{}":\n{}'.format(source, str(e)))
else:
raise e
class AgendaParser(object):
@ -230,7 +233,7 @@ class AgendaParser(object):
self.run_config.set('run_name', entry.pop('run_name'))
config_parser = ConfigParser(self.wa_config, self.run_config,
self.jobs_config, self.plugin_cache)
config_parser.load(entry, source)
config_parser.load(entry, source, wrap_exceptions=False)
# PHASE 2: Getting "section" and "workload" entries.
sections = raw.pop("sections", [])