Browse code

Honour the verbosity setting in the config file

Previously, the 'verbosity' setting in the config file was always ignored.
We now honour it, but still allow it to be overridden on the commandline.

Richard van der Hoff authored on 2014/02/18 22:37:13
Showing 1 changed files
... ...
@@ -1944,7 +1944,6 @@ def main():
1944 1944
         if cmd.has_key("cmd"):
1945 1945
             commands[cmd["cmd"]] = cmd
1946 1946
 
1947
-    default_verbosity = Config().verbosity
1948 1947
     optparser = OptionParser(option_class=OptionAll, formatter=MyHelpFormatter())
1949 1948
     #optparser.disable_interspersed_args()
1950 1949
 
... ...
@@ -1958,7 +1957,6 @@ def main():
1958 1958
 
1959 1959
     optparser.set_defaults(encoding = preferred_encoding)
1960 1960
     optparser.set_defaults(config = config_file)
1961
-    optparser.set_defaults(verbosity = default_verbosity)
1962 1961
 
1963 1962
     optparser.add_option(      "--configure", dest="run_configure", action="store_true", help="Invoke interactive (re)configuration tool. Optionally use as '--configure s3://some-bucket' to test access to a specific bucket instead of attempting to list them all.")
1964 1963
     optparser.add_option("-c", "--config", dest="config", metavar="FILE", help="Config file name. Defaults to %default")
... ...
@@ -2068,7 +2066,7 @@ def main():
2068 2068
 
2069 2069
     ## Some mucking with logging levels to enable
2070 2070
     ## debugging/verbose output for config file parser on request
2071
-    logging.basicConfig(level=options.verbosity,
2071
+    logging.basicConfig(level=options.verbosity or Config().verbosity,
2072 2072
                         format='%(levelname)s: %(message)s',
2073 2073
                         stream = sys.stderr)
2074 2074
 
... ...
@@ -2100,9 +2098,8 @@ def main():
2100 2100
             error(u"Consider using --configure parameter to create one.")
2101 2101
             sys.exit(1)
2102 2102
 
2103
-    ## And again some logging level adjustments
2104
-    ## according to configfile and command line parameters
2105
-    if options.verbosity != default_verbosity:
2103
+    # allow commandline verbosity config to override config file
2104
+    if options.verbosity is not None:
2106 2105
         cfg.verbosity = options.verbosity
2107 2106
     logging.root.setLevel(cfg.verbosity)
2108 2107