Page 1 of 1

Suppressing Output During Download with API

Posted: Tue Apr 16, 2024 11:42 am America/New_York
by CSDA - fpolicel
Hi,
I am downloading SWOT data using the API in Python.
I want to suppress all of the update information, and I was only partially successful with my code below.
Specically, I am still repeatedly getting "Loading widget..." as an output. I think this happens each time it downloads a dataset.
Thank you,
Fritz Policelli
NASA, GSFC

with contextlib.redirect_stdout(output_buffer), contextlib.redirect_stderr(output_buffer):
results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RiverSP_2.0', bounding_box=
(x_min,y_min,x_max,y_max))
directory = 'reach_id_' + str(reach_id) + 'SWOT_data'
if not os.path.exists(directory):
os.makedirs(directory)
for result in results:
with contextlib.redirect_stdout(output_buffer), contextlib.redirect_stderr(output_buffer):
earthaccess.download([result], directory)