TNO Intern

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