From f7b4eb8d8c65d5bf3701a35053f7f365e191c070 Mon Sep 17 00:00:00 2001 From: Alan De Smet <alan.desmet@ssec.wisc.edu> Date: Fri, 3 Sep 2021 19:53:27 +0000 Subject: [PATCH] Output to stdout not stderr This matches the old aitf-mirror behavior (and matching tests) --- example/aitf-data-for-run | 10 +++++----- example/aitf-update-cache | 11 ++++++----- example/aitf/progress.py | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/example/aitf-data-for-run b/example/aitf-data-for-run index cfa29c3..1697c6f 100755 --- a/example/aitf-data-for-run +++ b/example/aitf-data-for-run @@ -81,9 +81,9 @@ def hack_oisst_preliminary_filename(filename): def yes_download_report(name, stats): - sys.stderr.write(name+"\n") + sys.stdout.write(name+"\n") for x in stats.report(): - sys.stderr.write(" "+x+"\n") + sys.stdout.write(" "+x+"\n") def no_download_report(name, stats): pass @@ -116,21 +116,21 @@ def main(): try: - if args.want_progress: sys.stderr.write("Acquiring SST\n") + if args.want_progress: sys.stdout.write("Acquiring SST\n") sststats = aitf.ancil.SST.download_for_time(args.scan_time, args.cache, do_download = do_download, progress=progress) sst_files = sststats.all_files() log_download_report("SST Download Summary", sststats) # using SST instead of GFS to show that # DownloadStatistics are interchangable. - if args.want_progress: sys.stderr.write("Acquiring GFS\n") + if args.want_progress: sys.stdout.write("Acquiring GFS\n") gfsstats = aitf.ancil.GFS.download_for_time(args.scan_time, args.cache, do_download = do_download, progress=progress) gfs_files = gfsstats.all_files() log_download_report("GFS Download Summary", gfsstats) log_download_report("Total Download Summary", sststats + gfsstats) - if args.want_progress: sys.stderr.write("Symbolically linking into place\n") + if args.want_progress: sys.stdout.write("Symbolically linking into place\n") all_files = list(sst_files) + list(gfs_files) for destination in args.destination: for file in all_files: diff --git a/example/aitf-update-cache b/example/aitf-update-cache index b394c07..c9ff249 100755 --- a/example/aitf-update-cache +++ b/example/aitf-update-cache @@ -93,9 +93,9 @@ def parse_args(): def yes_download_report(name, stats): - sys.stderr.write(name+"\n") + sys.stdout.write(name+"\n") for x in stats.report(): - sys.stderr.write(" "+x+"\n") + sys.stdout.write(" "+x+"\n") def no_download_report(name, stats): pass @@ -219,9 +219,10 @@ def main(): from datetime import datetime expiration = (datetime.now() - args.expiration).timestamp() stats = delete_old_files(args.dir, expiration) - logging.summary('Expiring Old Data Summary') - logging.summary(f' Removed {stats.num_deleted} files totaling {stats.size_deleted} bytes') - logging.summary(f' Kept {stats.num_kept} files totaling {stats.size_kept} bytes') + if args.want_summary: + sys.stdout.write('Expiring Old Data Summary\n') + sys.stdout.write(f' Removed {stats.num_deleted} files totaling {stats.size_deleted} bytes\n') + sys.stdout.write(f' Kept {stats.num_kept} files totaling {stats.size_kept} bytes\n') return 0 diff --git a/example/aitf/progress.py b/example/aitf/progress.py index bdbeba5..2996625 100755 --- a/example/aitf/progress.py +++ b/example/aitf/progress.py @@ -28,15 +28,15 @@ human_bytes = csppfetch.human_bytes class Progress(csppfetch.Progress): def start_attempt(self, stats): - sys.stderr.write(f"Attempt {stats.current_attempt} out of maximum {stats.max_attempts}\n") + sys.stdout.write(f"Attempt {stats.current_attempt} out of maximum {stats.max_attempts}\n") def start_fileset(self, stats): - sys.stderr.write( f" Working on {stats.current_fileset_description}\n") + sys.stdout.write( f" Working on {stats.current_fileset_description}\n") def finished_file(self, stats, local_path, is_cache_hit): reason = "downloaded" if is_cache_hit: reason = "found in local cache" - sys.stderr.write(f" {local_path} {reason}. (Downloaded {len(stats.downloaded_files)} files, {human_bytes(stats.downloaded_size)}. Found in cache {len(stats.cached_files)} files, {human_bytes(stats.cached_size)})\n") + sys.stdout.write(f" {local_path} {reason}. (Downloaded {len(stats.downloaded_files)} files, {human_bytes(stats.downloaded_size)}. Found in cache {len(stats.cached_files)} files, {human_bytes(stats.cached_size)})\n") -- GitLab