Skip to content

Commit

Permalink
fix(cli): check minoc status
Browse files Browse the repository at this point in the history
  • Loading branch information
tjzegmott committed Jun 20, 2024
1 parent 484562c commit 6a0d6df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions dtcli/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def ps(
except Exception as e:
error_console.print(e)
return None

# Check Canfar status.
canfar_up = cadcclient.status()
if not canfar_up:
error_console.print(
"Either Minoc is down or certificate is invalid.", style="bold yellow"
)

try:
files, policies = functions.ps(scope, dataset, verbose, quiet)
if isinstance(files, str) or isinstance(policies, str):
Expand Down
13 changes: 10 additions & 3 deletions dtcli/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from dtcli.config import procure
from dtcli.src.functions import find_missing_dataset_files, get_files
from dtcli.utilities.cadcclient import size
from dtcli.utilities import cadcclient
from dtcli.utilities.utilities import set_log_level, validate_scope

logger = logging.getLogger("pull")
Expand Down Expand Up @@ -42,7 +42,7 @@
@click.option("-q", "--quiet", is_flag=True, help="Set log level to ERROR.")
@click.option("--force", "-f", is_flag=True, help="Do not prompt for confirmation.")
@click.pass_context
def pull(
def pull( # noqa: C901
ctx: click.Context,
scope: str,
dataset: str,
Expand Down Expand Up @@ -97,6 +97,13 @@ def pull(
error_console.print(e)
return None

# Check Canfar status.
canfar_up = cadcclient.status()
if not canfar_up:
error_console.print(
"Either Minoc is down or certificate is invalid.", style="bold yellow"
)

# Find files missing from localhost.
console.print(f"\nSearching for files for {dataset} {scope}...\n")
files = find_missing_dataset_files(scope, dataset, directory, verbose)
Expand All @@ -111,7 +118,7 @@ def pull(
if len(files_paths) > 0:
common_path = path.commonpath(["/" + f for f in files_paths])
try:
to_download_size = size(common_path)
to_download_size = cadcclient.size(common_path)
except SSLError:
error_console.print(
"""
Expand Down
11 changes: 11 additions & 0 deletions dtcli/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def scout( # noqa: C901
)
return {"error": "No config. Create one with `datatrail config init`."}

# Check Canfar status.
canfar_up = cadcclient.status()
if not canfar_up:
error_console.print(
"Either Minoc is down or certificate is invalid.", style="bold yellow"
)

# Scout dataset.
endpoint = (
f"/query/dataset/scout?name={dataset}"
Expand Down Expand Up @@ -113,6 +120,10 @@ def scout( # noqa: C901
error_console.print("Query failed.")
error_console.print(error)
return None
except Exception as error:
error_console.print("Query failed.")
error_console.print(error)
return None
data[scope]["observed"]["minoc"] = count

keys_missing_in_observed = list(
Expand Down

0 comments on commit 6a0d6df

Please sign in to comment.