diff --git a/subunit2sql/analysis/graph.py b/subunit2sql/analysis/graph.py index 2c3c0b7..0c95536 100755 --- a/subunit2sql/analysis/graph.py +++ b/subunit2sql/analysis/graph.py @@ -27,6 +27,7 @@ import subunit2sql.analysis.run_time from subunit2sql import shell CONF = cfg.CONF +CONF.import_opt('verbose', 'subunit2sql.db.api') SHELL_OPTS = [ cfg.StrOpt('title', short='t', help='Optional title to use for the graph ' @@ -41,8 +42,6 @@ SHELL_OPTS = [ cfg.StrOpt('stop-date', short='s', help='Stop date for the graph only data from before this date ' 'will be used. Uses ISO 8601 format: 1914-06-28'), - cfg.BoolOpt('verbose', short='v', - help='Verbose output including logging of SQL statements'), ] diff --git a/subunit2sql/db/api.py b/subunit2sql/db/api.py index 2feafee..6b70d87 100644 --- a/subunit2sql/db/api.py +++ b/subunit2sql/db/api.py @@ -28,6 +28,9 @@ from subunit2sql import exceptions from subunit2sql import read_subunit CONF = cfg.CONF +CONF.register_cli_opt(cfg.BoolOpt('verbose', short='v', default=False, + help='Verbose output including logging of ' + 'SQL statements')) DAY_SECONDS = 60 * 60 * 24 @@ -60,7 +63,7 @@ def get_session(autocommit=True, expire_on_commit=False): # if --verbose was specified, turn on SQL logging # note that this is done after the session has been initialized so that # we can override the default sqlalchemy logging - if CONF.verbose: + if CONF.get('verbose', False): logging.basicConfig() logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) diff --git a/subunit2sql/migrations/cli.py b/subunit2sql/migrations/cli.py index 7da86c6..2289efa 100644 --- a/subunit2sql/migrations/cli.py +++ b/subunit2sql/migrations/cli.py @@ -41,13 +41,12 @@ MIGRATION_OPTS = [ "out the microseconds from the timestamps this will skip " "converting the microsecond field from the timestamps " "into a separate column"), - cfg.BoolOpt('verbose', short='v', - help='Verbose output including logging of SQL statements'), ] CONF = cfg.CONF CONF.register_cli_opts(options.database_opts, group='database') CONF.register_cli_opts(MIGRATION_OPTS) +CONF.import_opt('verbose', 'subunit2sql.db.api') def do_alembic_command(config, cmd, *args, **kwargs): diff --git a/subunit2sql/shell.py b/subunit2sql/shell.py index 3876c47..5b99d47 100644 --- a/subunit2sql/shell.py +++ b/subunit2sql/shell.py @@ -25,6 +25,7 @@ from subunit2sql import exceptions from subunit2sql import read_subunit as subunit CONF = cfg.CONF +CONF.import_opt('verbose', 'subunit2sql.db.api') SHELL_OPTS = [ cfg.MultiStrOpt('subunit_files', positional=True, @@ -41,8 +42,6 @@ SHELL_OPTS = [ cfg.StrOpt('attr_regex', default='\[(.*)\]', help='The regex to use to extract the comma separated list of ' 'test attributes from the test_id'), - cfg.BoolOpt('verbose', short='v', - help='Verbose output including logging of SQL statements'), ] _version_ = version.VersionInfo('subunit2sql').version_string()