TNO Intern

Skip to content
Commits on Source (2)
......@@ -4,6 +4,9 @@
# 2023-10, Arjo Segers
# Tools to access Copernicus DataSpace.
#
# 2023-10, Arjo Segers
# Trap errors from "requests.get" during inquire.
#
########################################################################
###
......@@ -293,10 +296,10 @@ class CSO_DataSpace_Inquire(utopya.UtopyaRc):
maxtry = 5
# repeat a few times if necessary:
while ntry <= maxtry:
# send query to search page; no authorization is needed ...
r = requests.get(search_url, params=params)
# check status, raise error if request failed:
try:
# send query to search page; no authorization is needed ...
r = requests.get(search_url, params=params)
# check status, raise error if request failed:
r.raise_for_status()
except Exception as err:
msg = str(err)
......
......@@ -21,6 +21,9 @@
# 2023-09, Arjo Segers
# Fixed bug in definition of listing file dates from rcfile settings.
#
# 2023-11, Arjo Segers
# Improved check on undefined 'href' fields in inquiry listing.
#
#
########################################################################
......@@ -2469,8 +2472,14 @@ class CSO_S5p_Convert(utopya.UtopyaRc):
# info ..
logging.info(" not present yet, download ...")
# check ..
if ("href" not in rec.keys()) or numpy.isnan(rec["href"]):
logging.error(f"cannot download, no 'href' element in record ...")
if "href" not in rec.keys():
logging.error(f"cannot download, no 'href' column in inquiry ...")
logging.error(f"check inquiry table: {filename}")
raise Exception
# endif
if pandas.isna(rec["href"]):
logging.error(f"cannot download, empty 'href' element in inquiry ...")
logging.error(f"check inquiry table: {filename}")
raise Exception
# endif
# download ...
......