From 6fdb244e46a62253f4654681ec5e5d76431f49f0 Mon Sep 17 00:00:00 2001 From: MWSammons <82555500+MWSammons@users.noreply.github.com> Date: Thu, 9 May 2024 15:13:53 -0400 Subject: [PATCH] fix(functions.py): changed error catching checks to be for dictionaries with error keys in them as opposed to strings (#74) Co-authored-by: Mawson Sammons --- dtcli/src/functions.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dtcli/src/functions.py b/dtcli/src/functions.py index 578905e..68c88e5 100644 --- a/dtcli/src/functions.py +++ b/dtcli/src/functions.py @@ -142,12 +142,12 @@ def ps( r = requests.get(url) logger.debug(f"Status: {r.status_code}.") policy_response = utilities.decode_response(r) - if "object has no attribute" in policy_response and isinstance( - files_response, str + if ("object has no attribute" in policy_response) and ( + "error" in files_response ): - raise Exception(f"Could not find {dataset} {scope} in Datatrail.") - elif isinstance(files_response, str): - return None, policy_response + raise Exception(files_response["error"]) + elif "error" in files_response: + return None, policy_response # type: ignore return files_response, policy_response # type: ignore except requests.exceptions.ConnectionError as e: @@ -219,8 +219,8 @@ def find_missing_dataset_files( # find dataset dataset_locations = get_dataset_file_info(scope, dataset, verbose=verbose) - if isinstance(dataset_locations, str): - print(f"Could not find the dataset: {scope}, {dataset}") + if "error" in dataset_locations: + print(dataset_locations["error"]) return {} # check for local copy of the data.