diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4365594a..f4e46399 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -108,7 +108,7 @@ jobs: scripts/build.sh ${{ needs.create_release.outputs.version }} ${{ needs.create_release.outputs.branch }} ${{ matrix.build_type }} echo "Contents of dist directory:" ls -altr ${{ github.workspace }}/dist/ - docker rm -f $(docker ps -aq) + docker rm -f $(docker ps -aq) || true - name: Save sha512sum for ${{ steps.asset_details.outputs.FINAL_ASSET_NAME }} run: | diff --git a/README.md b/README.md index b4d0e691..6353d4f1 100644 --- a/README.md +++ b/README.md @@ -9,26 +9,26 @@ SKALE Node CLI, part of the SKALE suite of validator tools, is the command line ## Table of Contents 1. [Installation](#installation) - 1.1 [Standard Node Binary](#standard-node-binary) - 1.2 [Sync Node Binary](#sync-node-binary) - 1.3 [Mirage Node Binary](#mirage-node-binary) - 1.4 [Permissions and Testing](#permissions-and-testing) + 1. [Standard Node Binary](#standard-node-binary) + 2. [Sync Node Binary](#sync-node-binary) + 3. [Mirage Node Binary](#mirage-node-binary) + 4. [Permissions and Testing](#permissions-and-testing) 2. [Standard Node Usage (`skale` - Normal Build)](#standard-node-usage-skale---normal-build) - 2.1 [Top level commands (Standard)](#top-level-commands-standard) - 2.2 [Node commands (Standard)](#node-commands-standard) - 2.3 [Wallet commands (Standard)](#wallet-commands-standard) - 2.4 [sChain commands (Standard)](#schain-commands-standard) - 2.5 [Health commands (Standard)](#health-commands-standard) - 2.6 [SSL commands (Standard)](#ssl-commands-standard) - 2.7 [Logs commands (Standard)](#logs-commands-standard) - 2.8 [Resources allocation commands (Standard)](#resources-allocation-commands-standard) + 1. [Top level commands (Standard)](#top-level-commands-standard) + 2. [Node commands (Standard)](#node-commands-standard) + 3. [Wallet commands (Standard)](#wallet-commands-standard) + 4. [sChain commands (Standard)](#schain-commands-standard) + 5. [Health commands (Standard)](#health-commands-standard) + 6. [SSL commands (Standard)](#ssl-commands-standard) + 7. [Logs commands (Standard)](#logs-commands-standard) + 8. [Resources allocation commands (Standard)](#resources-allocation-commands-standard) 3. [Sync Node Usage (`skale` - Sync Build)](#sync-node-usage-skale---sync-build) - 3.1 [Top level commands (Sync)](#top-level-commands-sync) - 3.2 [Sync node commands](#sync-node-commands) + 1. [Top level commands (Sync)](#top-level-commands-sync) + 2. [Sync node commands](#sync-node-commands) 4. [Mirage Node Usage (`mirage`)](#mirage-node-usage-mirage) - 4.1 [Top level commands (Mirage)](#top-level-commands-mirage) - 4.2 [Mirage Boot commands](#mirage-boot-commands) - 4.3 [Mirage Node commands](#mirage-node-commands) + 1. [Top level commands (Mirage)](#top-level-commands-mirage) + 2. [Mirage Boot commands](#mirage-boot-commands) + 3. [Mirage Node commands](#mirage-node-commands) 5. [Exit codes](#exit-codes) 6. [Development](#development) diff --git a/node_cli/cli/exit.py b/node_cli/cli/exit.py index 92322bd9..c7f57db3 100644 --- a/node_cli/cli/exit.py +++ b/node_cli/cli/exit.py @@ -24,10 +24,10 @@ from node_cli.utils.print_formatters import print_exit_status from node_cli.utils.helper import error_exit, get_request, post_request, abort_if_false from node_cli.utils.exit_codes import CLIExitCodes -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts logger = logging.getLogger(__name__) -TEXTS = Texts() +TEXTS = safe_load_texts() BLUEPRINT_NAME = 'node' diff --git a/node_cli/cli/health.py b/node_cli/cli/health.py index de54d186..27607ecb 100644 --- a/node_cli/cli/health.py +++ b/node_cli/cli/health.py @@ -18,12 +18,12 @@ # along with this program. If not, see . import click -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts from node_cli.core.health import get_containers, get_schains_checks, get_sgx_info -G_TEXTS = Texts() +G_TEXTS = safe_load_texts() TEXTS = G_TEXTS['health'] diff --git a/node_cli/cli/lvmpy.py b/node_cli/cli/lvmpy.py index d795a78e..2e9772aa 100644 --- a/node_cli/cli/lvmpy.py +++ b/node_cli/cli/lvmpy.py @@ -20,11 +20,11 @@ import click from node_cli.utils.helper import abort_if_false -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts from lvmpy.src.app import run as run_lvmpy from lvmpy.src.health import heal_service -G_TEXTS = Texts() +G_TEXTS = safe_load_texts() TEXTS = G_TEXTS['lvmpy'] diff --git a/node_cli/cli/node.py b/node_cli/cli/node.py index 4c9e40e3..a7f3d17c 100644 --- a/node_cli/cli/node.py +++ b/node_cli/cli/node.py @@ -39,7 +39,8 @@ from node_cli.configs import DEFAULT_NODE_BASE_PORT from node_cli.configs.env import ALLOWED_ENV_TYPES from node_cli.utils.decorators import check_inited -from node_cli.utils.helper import abort_if_false, safe_load_texts, streamed_cmd, IP_TYPE +from node_cli.utils.helper import abort_if_false, streamed_cmd, IP_TYPE +from node_cli.utils.texts import safe_load_texts from node_cli.utils.meta import get_meta_info from node_cli.utils.print_formatters import print_meta_info diff --git a/node_cli/cli/resources_allocation.py b/node_cli/cli/resources_allocation.py index 9a518a2d..01825350 100644 --- a/node_cli/cli/resources_allocation.py +++ b/node_cli/cli/resources_allocation.py @@ -24,7 +24,8 @@ get_resource_allocation_info, generate_resource_allocation_config, ) -from node_cli.utils.helper import abort_if_false, safe_load_texts +from node_cli.utils.helper import abort_if_false +from node_cli.utils.texts import safe_load_texts from node_cli.utils.node_type import NodeType TEXTS = safe_load_texts() diff --git a/node_cli/cli/ssl.py b/node_cli/cli/ssl.py index e0b63f7c..e371e8ce 100644 --- a/node_cli/cli/ssl.py +++ b/node_cli/cli/ssl.py @@ -21,7 +21,8 @@ from terminaltables import SingleTable from node_cli.utils.exit_codes import CLIExitCodes -from node_cli.utils.helper import safe_load_texts, error_exit +from node_cli.utils.helper import error_exit +from node_cli.utils.texts import safe_load_texts from node_cli.configs.ssl import DEFAULT_SSL_CHECK_PORT, SSL_CERT_FILEPATH, SSL_KEY_FILEPATH from node_cli.core.ssl import check_cert, upload_cert, cert_status diff --git a/node_cli/cli/sync_node.py b/node_cli/cli/sync_node.py index ea4ee280..5f0a5217 100644 --- a/node_cli/cli/sync_node.py +++ b/node_cli/cli/sync_node.py @@ -25,10 +25,10 @@ from node_cli.utils.helper import ( abort_if_false, error_exit, - safe_load_texts, streamed_cmd, URL_TYPE, ) +from node_cli.utils.texts import safe_load_texts G_TEXTS = safe_load_texts() diff --git a/node_cli/core/host.py b/node_cli/core/host.py index e3279b75..7c9b2df6 100644 --- a/node_cli/core/host.py +++ b/node_cli/core/host.py @@ -54,7 +54,7 @@ from node_cli.core.nftables import NFTablesManager from node_cli.utils.helper import safe_mkdir -from node_cli.utils.helper import safe_load_texts +from node_cli.utils.texts import safe_load_texts TEXTS = safe_load_texts() diff --git a/node_cli/core/node.py b/node_cli/core/node.py index 19f4a688..f6b534cd 100644 --- a/node_cli/core/node.py +++ b/node_cli/core/node.py @@ -70,7 +70,7 @@ post_request, ) from node_cli.utils.meta import get_meta_info -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts from node_cli.utils.exit_codes import CLIExitCodes from node_cli.utils.decorators import check_not_inited, check_inited, check_user from node_cli.utils.docker_utils import ( @@ -86,7 +86,7 @@ logger = logging.getLogger(__name__) -TEXTS = Texts() +TEXTS = safe_load_texts() BASE_CONTAINERS_AMOUNT = 5 BLUEPRINT_NAME = 'node' diff --git a/node_cli/main.py b/node_cli/main.py index d1d152ec..8ec7420a 100644 --- a/node_cli/main.py +++ b/node_cli/main.py @@ -43,7 +43,8 @@ from node_cli.core.host import init_logs_dir from node_cli.utils.node_type import NodeType from node_cli.configs import LONG_LINE -from node_cli.utils.helper import safe_load_texts, init_default_logger +from node_cli.utils.helper import init_default_logger +from node_cli.utils.texts import safe_load_texts from node_cli.utils.helper import error_exit TEXTS = safe_load_texts() diff --git a/node_cli/utils/decorators.py b/node_cli/utils/decorators.py index f0d11e00..f72fea60 100644 --- a/node_cli/utils/decorators.py +++ b/node_cli/utils/decorators.py @@ -22,11 +22,11 @@ from node_cli.core.host import is_node_inited from node_cli.utils.global_config import get_system_user from node_cli.utils.helper import error_exit, is_user_valid, get_g_conf_user -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts from node_cli.utils.exit_codes import CLIExitCodes -TEXTS = Texts() +TEXTS = safe_load_texts() def check_not_inited(f): diff --git a/node_cli/utils/helper.py b/node_cli/utils/helper.py index 07dbef19..c9b21d9f 100644 --- a/node_cli/utils/helper.py +++ b/node_cli/utils/helper.py @@ -50,7 +50,6 @@ from node_cli.utils.print_formatters import print_err_response from node_cli.utils.exit_codes import CLIExitCodes from node_cli.configs import ( - TEXT_FILE, ADMIN_HOST, ADMIN_PORT, HIDE_STREAM_LOG, @@ -187,14 +186,6 @@ def safe_get_config(config, key): return None -def safe_load_texts(): - with open(TEXT_FILE, 'r') as stream: - try: - return yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) - - def safe_load_yml(filepath): with open(filepath, 'r') as stream: try: diff --git a/node_cli/utils/print_formatters.py b/node_cli/utils/print_formatters.py index b5448d45..3ba9171b 100644 --- a/node_cli/utils/print_formatters.py +++ b/node_cli/utils/print_formatters.py @@ -29,9 +29,9 @@ from node_cli.configs import LONG_LINE from node_cli.configs.cli_logger import DEBUG_LOG_FILEPATH from node_cli.utils.meta import CliMeta -from node_cli.utils.texts import Texts +from node_cli.utils.texts import safe_load_texts -TEXTS = Texts() +TEXTS = safe_load_texts() def print_wallet_info(wallet): diff --git a/node_cli/utils/texts.py b/node_cli/utils/texts.py index d4813d27..718edd75 100644 --- a/node_cli/utils/texts.py +++ b/node_cli/utils/texts.py @@ -1,6 +1,16 @@ # -*- coding: utf-8 -*- # # This file is part of node-cli +# +# Copyright (C) 2025-Present SKALE Labs +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # @@ -11,16 +21,9 @@ from node_cli.configs import TEXT_FILE -class Texts: - def __init__(self): - self._texts = self._load() - - def __getitem__(self, key): - return self._texts.get(key) - - def _load(self): - with open(TEXT_FILE, 'r') as stream: - try: - return yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) +def safe_load_texts(): + with open(TEXT_FILE, 'r') as stream: + try: + return yaml.safe_load(stream) + except yaml.YAMLError as exc: + print(exc)