diff --git a/example/aitf-update-cache b/example/aitf-update-cache index 8d130f3e3d58662ec86418c2ce8b76cdfb7e16a8..bcbeebe836d6b25c8330999d271526ebc985a394 100755 --- a/example/aitf-update-cache +++ b/example/aitf-update-cache @@ -1,18 +1,12 @@ #! /usr/bin/python3 +# System modules import os import sys -import datetime as dt -import tempfile -sys.path.append(os.path.abspath('..')) -from csppfetch import DownloadStatistics -import aitf.ancil -import aitf.conlog import logging - -# Environment variable that can hold the path to the cache -CACHE_ENV="CSPP_GEO_AITF_CACHE" +import aitf.ancil +import aitf.conlog def parse_args(): @@ -23,10 +17,8 @@ def parse_args(): import argparse - default_expiration_days = 7 - ap = argparse.ArgumentParser( description="Maintain a local cache of dynamic data needed by the aitf in a local cache. By default downloads files not already present going back {days} days from the current system time, and deletes files from the cache that are older than {days} days.".format(days=default_expiration_days), epilog=""" @@ -37,7 +29,7 @@ def parse_args(): is recommended. The form "20210581450000" (YYYYjjjHHMMSSt) is also understood. """, - formatter_class = SmartFormatter + formatter_class = SmartFormatter # Protects blank line in epilog ) add_cache_dir_arg(ap) @@ -68,14 +60,15 @@ def parse_args(): args = ap.parse_args() + process_verbosity(args) + if args.oldest is None: args.oldest = args.newest - args.download_window - process_verbosity(args) - return args + def log_download_report(name, stats): logging.summary(name) for x in stats.report(): @@ -85,7 +78,7 @@ def main(): aitf.conlog.setup_logging() args = parse_args() - sststats = DownloadStatistics() + sststats = aitf.ancil.SST.DownloadStatistics() aitf.ancil.SST.update_cache(args.dir, start_time=args.oldest, end_time=args.newest, @@ -93,7 +86,9 @@ def main(): ) log_download_report("SST Download Summary", sststats) - gfsstats = DownloadStatistics() + # using SST instead of GFS to show that + # DownloadStatistics are interchangable. + gfsstats = aitf.ancil.SST.DownloadStatistics() aitf.ancil.GFS.update_cache(args.dir, start_time=args.oldest, end_time=args.newest,