Skip to content

Commit 6a0d6df

Browse files
committed
fix(cli): check minoc status
1 parent 484562c commit 6a0d6df

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

dtcli/ps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ def ps(
6666
except Exception as e:
6767
error_console.print(e)
6868
return None
69+
70+
# Check Canfar status.
71+
canfar_up = cadcclient.status()
72+
if not canfar_up:
73+
error_console.print(
74+
"Either Minoc is down or certificate is invalid.", style="bold yellow"
75+
)
76+
6977
try:
7078
files, policies = functions.ps(scope, dataset, verbose, quiet)
7179
if isinstance(files, str) or isinstance(policies, str):

dtcli/pull.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from dtcli.config import procure
1212
from dtcli.src.functions import find_missing_dataset_files, get_files
13-
from dtcli.utilities.cadcclient import size
13+
from dtcli.utilities import cadcclient
1414
from dtcli.utilities.utilities import set_log_level, validate_scope
1515

1616
logger = logging.getLogger("pull")
@@ -42,7 +42,7 @@
4242
@click.option("-q", "--quiet", is_flag=True, help="Set log level to ERROR.")
4343
@click.option("--force", "-f", is_flag=True, help="Do not prompt for confirmation.")
4444
@click.pass_context
45-
def pull(
45+
def pull( # noqa: C901
4646
ctx: click.Context,
4747
scope: str,
4848
dataset: str,
@@ -97,6 +97,13 @@ def pull(
9797
error_console.print(e)
9898
return None
9999

100+
# Check Canfar status.
101+
canfar_up = cadcclient.status()
102+
if not canfar_up:
103+
error_console.print(
104+
"Either Minoc is down or certificate is invalid.", style="bold yellow"
105+
)
106+
100107
# Find files missing from localhost.
101108
console.print(f"\nSearching for files for {dataset} {scope}...\n")
102109
files = find_missing_dataset_files(scope, dataset, directory, verbose)
@@ -111,7 +118,7 @@ def pull(
111118
if len(files_paths) > 0:
112119
common_path = path.commonpath(["/" + f for f in files_paths])
113120
try:
114-
to_download_size = size(common_path)
121+
to_download_size = cadcclient.size(common_path)
115122
except SSLError:
116123
error_console.print(
117124
"""

dtcli/scout.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def scout( # noqa: C901
7878
)
7979
return {"error": "No config. Create one with `datatrail config init`."}
8080

81+
# Check Canfar status.
82+
canfar_up = cadcclient.status()
83+
if not canfar_up:
84+
error_console.print(
85+
"Either Minoc is down or certificate is invalid.", style="bold yellow"
86+
)
87+
8188
# Scout dataset.
8289
endpoint = (
8390
f"/query/dataset/scout?name={dataset}"
@@ -113,6 +120,10 @@ def scout( # noqa: C901
113120
error_console.print("Query failed.")
114121
error_console.print(error)
115122
return None
123+
except Exception as error:
124+
error_console.print("Query failed.")
125+
error_console.print(error)
126+
return None
116127
data[scope]["observed"]["minoc"] = count
117128

118129
keys_missing_in_observed = list(

0 commit comments

Comments
 (0)