From 1ae0a395ba21fd209fcdbfe8595ea23809b16379 Mon Sep 17 00:00:00 2001 From: AdamTheisen Date: Thu, 21 Nov 2024 14:46:40 -0600 Subject: [PATCH] ENH: Updating plotting and error handling --- act/discovery/arm.py | 5 ++++- examples/workflows/plot_amf3_comparisons.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/act/discovery/arm.py b/act/discovery/arm.py index 1fda756913..11b8792dcf 100644 --- a/act/discovery/arm.py +++ b/act/discovery/arm.py @@ -112,7 +112,10 @@ def download_arm_data(username, token, datastream, startdate, enddate, time=None # get url response, read the body of the message, # and decode from bytes type to utf-8 string - response_body = urlopen(query_url).read().decode('utf-8') + try: + response_body = urlopen(query_url).read().decode('utf-8') + except Exception as error: + print(error + ' for url: ' + query_url) # if the response is an html doc, then there was an error with the user if response_body[1:14] == '!DOCTYPE html': raise ConnectionRefusedError('Error with user. Check username or token.') diff --git a/examples/workflows/plot_amf3_comparisons.py b/examples/workflows/plot_amf3_comparisons.py index abc73ae53d..3e239c1243 100644 --- a/examples/workflows/plot_amf3_comparisons.py +++ b/examples/workflows/plot_amf3_comparisons.py @@ -114,3 +114,5 @@ ax.legend(loc=2) plt.show() +else: + pass