Skip to content

Commit

Permalink
Add error reporting to generate_sample.sh on import failure.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Anton Frolov committed May 31, 2013
1 parent f30afa6 commit 27e2613
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tools/conf/extract_opts.py
Expand Up @@ -79,12 +79,9 @@ def _print_module(mod_str):
mod_str = mod_str[:mod_str.rfind(".")]
try:
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:
sys.stderr.write("Failed to collect options from module %s: %s\n" % (
mod_str, str(e)))
return
_list_opts(mod_obj, mod_str)

Expand Down

0 comments on commit 27e2613

Please sign in to comment.