|
2 | 2 |
|
3 | 3 | import json |
4 | 4 | import logging |
5 | | -from typing import Any, Dict, List, Union |
| 5 | +from typing import Any, Dict, List, Tuple, Union |
6 | 6 |
|
7 | 7 | import requests |
8 | 8 | from requests.models import Response |
| 9 | +from rich.console import Console |
| 10 | + |
| 11 | +from dtcli.utilities import cadcclient |
9 | 12 |
|
10 | 13 | try: |
11 | 14 | from packaging.version import parse |
@@ -133,3 +136,26 @@ def cli_is_latest_release() -> bool: |
133 | 136 | return current_version == get_latest_released_version() |
134 | 137 | except (ConnectionError, PackageNotFoundError): |
135 | 138 | return True |
| 139 | + |
| 140 | + |
| 141 | +def check_canfar_status(console: Console) -> Tuple[bool, bool]: |
| 142 | + """Checks the status of Luskan and Minoc. |
| 143 | +
|
| 144 | + Args: |
| 145 | + console: Console to print status messages to. |
| 146 | +
|
| 147 | + Returns: |
| 148 | + Tuple[bool, bool]: Status of Minoc and Luskan, respectively. |
| 149 | + """ |
| 150 | + # Check Canfar status. |
| 151 | + minoc_up, luskan_up = cadcclient.status() |
| 152 | + if not minoc_up: |
| 153 | + console.print(":warning: Minoc is down!", style="bold yellow") |
| 154 | + if not luskan_up: |
| 155 | + console.print(":warning: Luskan is down!", style="bold yellow") |
| 156 | + if not minoc_up or not luskan_up: |
| 157 | + console.print( |
| 158 | + "See https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/en/status/ for service availability.", # noqa: E501 |
| 159 | + style="bold yellow", |
| 160 | + ) |
| 161 | + return minoc_up, luskan_up |
0 commit comments