From 398d8bf58ae9107e4d886529690fb5d9658262b3 Mon Sep 17 00:00:00 2001
From: Alan De Smet <alan.desmet@ssec.wisc.edu>
Date: Fri, 6 Aug 2021 15:54:56 -0500
Subject: [PATCH] Use logging.progress if available.
Only for a few very high level things. If not available, route it to
logging.info
---
csppfetch/__init__.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/csppfetch/__init__.py b/csppfetch/__init__.py
index 54bd1db..b74483b 100644
--- a/csppfetch/__init__.py
+++ b/csppfetch/__init__.py
@@ -37,6 +37,15 @@ if sys.version_info < MIN_PYTHON_TUPLE:
+def logprogress(msg):
+ """ Pass to logging.progress if available, otherwise logging.info """
+ try:
+ logging.progress(msg)
+ return
+ except:
+ pass
+ logging.info(msg)
+
@@ -778,15 +787,17 @@ class Downloader:
for attempt in range(1, retries+1):
if retries > 1:
- logging.info(f"Attempt {attempt}")
+ logprogress(f"Attempt {attempt}")
for fileset in filesets:
description = fileset.description
expected = fileset.expected
urls_to_files = fileset.urls_to_files
- logging.info(f"Working on {description}")
+ logprogress(f" Working on {description}")
+ logging.info(f" files to get: {urls_to_files}")
for base_url in base_urls:
full_urls_to_file = {base_url+suffix: dst+"/"+value for suffix,value in urls_to_files.items()}
+ logging.info(f" Trying {base_url}")
try:
logging.debug(f"Considering {full_urls_to_file}")
--
GitLab