From a8c0f3ded414c4e8d4fbca9529bfda7610531841 Mon Sep 17 00:00:00 2001 From: MWSammons <82555500+MWSammons@users.noreply.github.com> Date: Fri, 10 May 2024 14:02:43 -0400 Subject: [PATCH] =?UTF-8?q?fix(functions):=20changed=20return=20of=20find?= =?UTF-8?q?=5Fmissing=5Fdatasets=20to=20always=20ret=E2=80=A6=20(#76)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(functions): changed return of find_missing_datasets to always return a consistent data type * refactor(cli-ps-and-pull): simplify error message and standardise display method Signed-off-by: Tarik Zegmott --------- Signed-off-by: Tarik Zegmott Co-authored-by: Mawson Sammons Co-authored-by: Tarik Zegmott --- dtcli/ps.py | 2 +- dtcli/pull.py | 5 ++++- dtcli/src/functions.py | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dtcli/ps.py b/dtcli/ps.py index 21e93f0..1e57cbf 100644 --- a/dtcli/ps.py +++ b/dtcli/ps.py @@ -69,7 +69,7 @@ def ps( try: files, policies = functions.ps(scope, dataset, verbose, quiet) except Exception as e: - logger.error(e) + error_console.print(e) return None if show_files and files: diff --git a/dtcli/pull.py b/dtcli/pull.py index bd78134..a487adb 100644 --- a/dtcli/pull.py +++ b/dtcli/pull.py @@ -100,7 +100,10 @@ def pull( # Find files missing from localhost. console.print(f"\nSearching for files for {dataset} {scope}...\n") files = find_missing_dataset_files(scope, dataset, directory, verbose) - if len(files["missing"]) == 0 and len(files["existing"]) == 0: + if files.get("error"): + error_console.print(files["error"]) + return None + elif len(files["missing"]) == 0 and len(files["existing"]) == 0: console.print("No files found at minoc.", style="bold red") return None files_paths = [f.replace("cadc:CHIMEFRB", "") for f in files["missing"]] diff --git a/dtcli/src/functions.py b/dtcli/src/functions.py index 68c88e5..cc32568 100644 --- a/dtcli/src/functions.py +++ b/dtcli/src/functions.py @@ -220,8 +220,7 @@ def find_missing_dataset_files( # find dataset dataset_locations = get_dataset_file_info(scope, dataset, verbose=verbose) if "error" in dataset_locations: - print(dataset_locations["error"]) - return {} + return {"error": dataset_locations["error"]} # check for local copy of the data. logger.info("Checking for local copies of files.")