diff --git a/example/aitf-data-for-run b/example/aitf-data-for-run index 7b3e66b2239e950228f19f81a82ebd10392fcc50..cfa29c3858247554d54017304278a5b0fae615bf 100755 --- a/example/aitf-data-for-run +++ b/example/aitf-data-for-run @@ -80,10 +80,13 @@ def hack_oisst_preliminary_filename(filename): return re.sub(r'(avhrr-only-v2.\d{8})_preliminary(.nc)', r'\1\2', filename) -def log_download_report(name, stats): - logging.summary(name) +def yes_download_report(name, stats): + sys.stderr.write(name+"\n") for x in stats.report(): - logging.summary(" "+x) + sys.stderr.write(" "+x+"\n") + +def no_download_report(name, stats): + pass @@ -91,6 +94,11 @@ def main(): aitf.conlog.setup_logging() args = parse_args() + if args.want_summary: + log_download_report = yes_download_report + else: + log_download_report = no_download_report + do_download = not args.cache_only cache_dir = args.cache diff --git a/example/aitf-update-cache b/example/aitf-update-cache index 04be032c79d6224215cec9e00bd6ef4c955567cf..b394c070eac6e339b8445cf8b732ba1472664f04 100755 --- a/example/aitf-update-cache +++ b/example/aitf-update-cache @@ -92,10 +92,13 @@ def parse_args(): -def log_download_report(name, stats): - logging.summary(name) +def yes_download_report(name, stats): + sys.stderr.write(name+"\n") for x in stats.report(): - logging.summary(" "+x) + sys.stderr.write(" "+x+"\n") + +def no_download_report(name, stats): + pass class CleaningStats: def __init__(self): @@ -189,6 +192,11 @@ def main(): else: progress = None + if args.want_summary: + log_download_report = yes_download_report + else: + log_download_report = no_download_report + sststats = aitf.ancil.SST.update_cache(args.dir, start_time=args.oldest, end_time=args.newest, diff --git a/example/aitf/argparsetools.py b/example/aitf/argparsetools.py index c7ad4b5df4398880019b0d83dc4b898577908584..880e866320d196b8ad43d95bb883159af2f89bb1 100644 --- a/example/aitf/argparsetools.py +++ b/example/aitf/argparsetools.py @@ -36,13 +36,15 @@ def initialize_logging_level_info(): import logging global logging_levels # Need to delay until logging is configured - logging_levels = [ ('warnings', logging.WARNING) ] - # These are from conlog, but I don't want to depend on them. - if hasattr(logging,'SUMMARY'): logging_levels += [ ('a summary', logging.SUMMARY) ] - # Not a "real" logging level - logging_levels += [ ('progress', logging_levels[-1][1]) ] - logging_levels += [('general information', logging.INFO), - ('debugging information', logging.DEBUG) ] + logging_levels = [ + ('warnings', logging.WARNING), + # These next two are not "real" logging levels + # but they control output + ('a summary', logging.WARNING), + ('progress', logging.WARNING), + ('general information', logging.INFO), + ('debugging information', logging.DEBUG), + ] def add_verbose_quiet_args(parser): import logging @@ -73,10 +75,8 @@ def process_verbosity(args): args.log_level = logging_levels[args.verbosity][1] if args.silent: args.log_level = logging.ERROR - if args.verbosity >= 2: - args.want_progress = True - else: - args.want_progress = False + args.want_progress = args.verbosity >= 2 + args.want_summary = args.verbosity >= 1 logging.getLogger().setLevel(args.log_level) diff --git a/example/aitf/conlog.py b/example/aitf/conlog.py index 24457b21de803e6a79010fc9e149df79c6c29753..b3a6da09eae04d642362200a0c15bc02c5e5205a 100644 --- a/example/aitf/conlog.py +++ b/example/aitf/conlog.py @@ -20,19 +20,6 @@ import logging import sys -def create_log_level(level, name): - logging.addLevelName(level, name.upper()) - def logger_func(self, message, *args, **kws): - if self.isEnabledFor(level): - self._log(level, message, args, **kws) - def logging_func(message, *args, **kws): - logging.log(level, message, *args, **kws) - setattr(logging.Logger, name.lower(), logger_func) - setattr(logging, name.lower(), logging_func) - setattr(logging, name.upper(), level) - logging.basicConfig() - - def add_console_logging(): """ Log to console, prefixing entries with the log level @@ -68,6 +55,5 @@ def add_console_logging(): return console_handler def setup_logging(): - create_log_level(25, "SUMMARY") logging.basicConfig() add_console_logging()