Add error reporting to generate_sample.sh on import failure.
Currently tools/conf/generate_sample.sh collect options from project modules by importing each module and looking at it's global variables for instances of classes derived from cfg.Opt (or lists of such instances). Sometimes this import can fail due to various reasons, cfg.DuplicateOptError for example. And if import fails no options from imported module written to sample config file. Error reporting will at least warn user that some of options didn't get into sample config. Change-Id: I831464b1c1575c106d866a936a50ec74b2d44e59 Fixes: bug #1182611
This commit is contained in:
parent
f30afa6e70
commit
27e261376f
@ -79,12 +79,9 @@ def _print_module(mod_str):
|
|||||||
mod_str = mod_str[:mod_str.rfind(".")]
|
mod_str = mod_str[:mod_str.rfind(".")]
|
||||||
try:
|
try:
|
||||||
mod_obj = importutils.import_module(mod_str)
|
mod_obj = importutils.import_module(mod_str)
|
||||||
except (ValueError, AttributeError), err:
|
|
||||||
return
|
|
||||||
except ImportError, ie:
|
|
||||||
sys.stderr.write("%s\n" % str(ie))
|
|
||||||
return
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
sys.stderr.write("Failed to collect options from module %s: %s\n" % (
|
||||||
|
mod_str, str(e)))
|
||||||
return
|
return
|
||||||
_list_opts(mod_obj, mod_str)
|
_list_opts(mod_obj, mod_str)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user