Skip to content
Snippets Groups Projects
Commit f7b4eb8d authored by Alan De Smet's avatar Alan De Smet
Browse files

Output to stdout not stderr

This matches the old aitf-mirror behavior (and matching tests)
parent 9af23f39
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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
......
......@@ -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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment