Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 191-use-round_to_precision-in-percent_to_hive_percent
  • 289-cli-working-watched-tracked-accounts-works-inconsistent-with-tui
  • bw_image_fixes
  • bw_image_fixes2
  • bw_protected_branch_job_fixes
  • bw_wip_demo_prototype
  • change-governance-data
  • develop
  • jziebinski/accounts-management-revolution
  • jziebinski/bump-schemas
  • jziebinski/fix-after-cli-governance
  • jziebinski/fix-dashboard
  • jziebinski/improve-governance
  • jziebinski/make-button-disabled
  • jziebinski/mkudela/fix-cart
  • jziebinski/mkudela/issue-173
  • jziebinski/mkudela/issue-233
  • jziebinski/mzebrak/119-update-profile-name-regex
  • jziebinski/prepare-hp-delegate
  • jziebinski/prepare-hp-full
  • jziebinski/prepare-hp-power-down
  • jziebinski/prepare-operations-ui
  • jziebinski/prepare-user-view
  • jziebinski/proposals-improvements
  • jziebinski/savings-demonstration
  • jziebinski/strike-through-tabs
  • jziebinski/textual-bump
  • jziebinski/user-info
  • jziebisnki/prepare-governance
  • kmochocki/add-mr-template
  • kmochocki/beekeepy-ready-to-merge
  • kmochocki/beekeepy-wip
  • kmochocki/ci-reuse-hived
  • kmochocki/kudmich/haf-filling-machine
  • kmochocki/menu-bar
  • kmochocki/optimize-update-node-data-async
  • kmochocki/ui-errors
  • kmochocki/update-hive-submodule
  • kmochocki/update-submodule
  • kmochocki/wup-check
  • kudmich/beekeeper_on_many_sessions_tests
  • kudmich/block_log_multi_sign_backup
  • kudmich/block_log_open_sign_backup
  • kudmich/block_log_single_sign
  • kudmich/block_log_single_sign_backup
  • kudmich/full_block_generator
  • kudmich/haf-filling-machine
  • kudmich/haf-filling-machine-copy_for_mzebrak
  • kudmich/haf-filling-machine_first_base
  • kudmich/prepared_block_logs
  • kudmich/update_block_log_with_open_sign
  • kudmich_full_block_generator_on_bk
  • marek/prepare-block_log
  • marek/tui-test-onboarding1
  • marek/tui-test-witness-votes
  • marek/tui-test-witness-votes-2
  • marek/tui-test-witness-votes-3
  • marek/tui-tests-key-press
  • marek/tui-tests-key-press-log-toasts
  • master
  • mkudela/authority
  • mkudela/fix_node_data_two_grouops
  • mkudela/generate_operations_script
  • mkudela/input_autofill
  • mkudela/issue-261
  • mkudela/issue-373
  • mkudela/modify_authority
  • mkudela/mzebrak/textual-bump
  • mkudela/refactor_transaction_summary
  • mkudela/test
  • msobczyk/343-missing-sign-option
  • msobczyk/377-error-messages-in-cli-tests
  • msobczyk/396-remove-bindings-from-the-bottom-menu
  • msobczyk/399-dont-cancel-ongoing-work
  • msobczyk/403-migration-better-storage
  • msobczyk/403-migration-better-storage-fixup
  • msobczyk/403-migration-better-storage-squashed
  • msobczyk/403-migration-better-storage-with-pydantic
  • msobczyk/add-faketime-to-embedded-testnet-image
  • msobczyk/apr_text
  • msobczyk/bash-tests
  • msobczyk/change_docker_image_tags
  • msobczyk/cli-authority-tests2
  • msobczyk/cli-claims
  • msobczyk/cli-claims-tests
  • msobczyk/cli-hive-power-management
  • msobczyk/cli-savings-management2
  • msobczyk/cli-witness-properties
  • msobczyk/collect-authority
  • msobczyk/conftest-do-not-merge
  • msobczyk/display-authority-tee-in-ui
  • msobczyk/display-authority-tree-in-tui
  • msobczyk/encrypt-profile-tmp
  • msobczyk/fix_crash_on_double_button
  • msobczyk/improve-cli-testing-interface
  • msobczyk/issue-374
  • msobczyk/kmochocki/beekeepy
  • msobczyk/mzebrak/bump-tools
  • msobczyk/mzebrak/fix-cli-tests-logs-in-output
  • msobczyk/mzebrak/fix-for-positional-cli
  • 1.27.5.0
  • test-tag
  • v1.27.5.0
  • v1.27.5.1
  • v1.27.5.10
  • v1.27.5.11
  • v1.27.5.12
  • v1.27.5.13
  • v1.27.5.14
  • v1.27.5.15
  • v1.27.5.16
  • v1.27.5.17
  • v1.27.5.17b4
  • v1.27.5.18
  • v1.27.5.19
  • v1.27.5.2
  • v1.27.5.20
  • v1.27.5.21
  • v1.27.5.3
  • v1.27.5.4
  • v1.27.5.5
  • v1.27.5.6
  • v1.27.5.7
  • v1.27.5.8
  • v1.27.5.9
125 results

Target

Select target project
  • hive/clive
1 result
Select Git revision
  • 191-use-round_to_precision-in-percent_to_hive_percent
  • 289-cli-working-watched-tracked-accounts-works-inconsistent-with-tui
  • bw_image_fixes
  • bw_image_fixes2
  • bw_protected_branch_job_fixes
  • bw_wip_demo_prototype
  • change-governance-data
  • develop
  • jziebinski/accounts-management-revolution
  • jziebinski/bump-schemas
  • jziebinski/fix-after-cli-governance
  • jziebinski/fix-dashboard
  • jziebinski/improve-governance
  • jziebinski/make-button-disabled
  • jziebinski/mkudela/fix-cart
  • jziebinski/mkudela/issue-173
  • jziebinski/mkudela/issue-233
  • jziebinski/mzebrak/119-update-profile-name-regex
  • jziebinski/prepare-hp-delegate
  • jziebinski/prepare-hp-full
  • jziebinski/prepare-hp-power-down
  • jziebinski/prepare-operations-ui
  • jziebinski/prepare-user-view
  • jziebinski/proposals-improvements
  • jziebinski/savings-demonstration
  • jziebinski/strike-through-tabs
  • jziebinski/textual-bump
  • jziebinski/user-info
  • jziebisnki/prepare-governance
  • kmochocki/add-mr-template
  • kmochocki/beekeepy-ready-to-merge
  • kmochocki/beekeepy-wip
  • kmochocki/ci-reuse-hived
  • kmochocki/kudmich/haf-filling-machine
  • kmochocki/menu-bar
  • kmochocki/optimize-update-node-data-async
  • kmochocki/ui-errors
  • kmochocki/update-hive-submodule
  • kmochocki/update-submodule
  • kmochocki/wup-check
  • kudmich/beekeeper_on_many_sessions_tests
  • kudmich/block_log_multi_sign_backup
  • kudmich/block_log_open_sign_backup
  • kudmich/block_log_single_sign
  • kudmich/block_log_single_sign_backup
  • kudmich/full_block_generator
  • kudmich/haf-filling-machine
  • kudmich/haf-filling-machine-copy_for_mzebrak
  • kudmich/haf-filling-machine_first_base
  • kudmich/prepared_block_logs
  • kudmich/update_block_log_with_open_sign
  • kudmich_full_block_generator_on_bk
  • marek/prepare-block_log
  • marek/tui-test-onboarding1
  • marek/tui-test-witness-votes
  • marek/tui-test-witness-votes-2
  • marek/tui-test-witness-votes-3
  • marek/tui-tests-key-press
  • marek/tui-tests-key-press-log-toasts
  • master
  • mkudela/authority
  • mkudela/fix_node_data_two_grouops
  • mkudela/generate_operations_script
  • mkudela/input_autofill
  • mkudela/issue-261
  • mkudela/issue-373
  • mkudela/modify_authority
  • mkudela/mzebrak/textual-bump
  • mkudela/refactor_transaction_summary
  • mkudela/test
  • msobczyk/343-missing-sign-option
  • msobczyk/377-error-messages-in-cli-tests
  • msobczyk/396-remove-bindings-from-the-bottom-menu
  • msobczyk/399-dont-cancel-ongoing-work
  • msobczyk/403-migration-better-storage
  • msobczyk/403-migration-better-storage-fixup
  • msobczyk/403-migration-better-storage-squashed
  • msobczyk/403-migration-better-storage-with-pydantic
  • msobczyk/add-faketime-to-embedded-testnet-image
  • msobczyk/apr_text
  • msobczyk/bash-tests
  • msobczyk/change_docker_image_tags
  • msobczyk/cli-authority-tests2
  • msobczyk/cli-claims
  • msobczyk/cli-claims-tests
  • msobczyk/cli-hive-power-management
  • msobczyk/cli-savings-management2
  • msobczyk/cli-witness-properties
  • msobczyk/collect-authority
  • msobczyk/conftest-do-not-merge
  • msobczyk/display-authority-tee-in-ui
  • msobczyk/display-authority-tree-in-tui
  • msobczyk/encrypt-profile-tmp
  • msobczyk/fix_crash_on_double_button
  • msobczyk/improve-cli-testing-interface
  • msobczyk/issue-374
  • msobczyk/kmochocki/beekeepy
  • msobczyk/mzebrak/bump-tools
  • msobczyk/mzebrak/fix-cli-tests-logs-in-output
  • msobczyk/mzebrak/fix-for-positional-cli
  • 1.27.5.0
  • test-tag
  • v1.27.5.0
  • v1.27.5.1
  • v1.27.5.10
  • v1.27.5.11
  • v1.27.5.12
  • v1.27.5.13
  • v1.27.5.14
  • v1.27.5.15
  • v1.27.5.16
  • v1.27.5.17
  • v1.27.5.17b4
  • v1.27.5.18
  • v1.27.5.19
  • v1.27.5.2
  • v1.27.5.20
  • v1.27.5.21
  • v1.27.5.3
  • v1.27.5.4
  • v1.27.5.5
  • v1.27.5.6
  • v1.27.5.7
  • v1.27.5.8
  • v1.27.5.9
125 results
Show changes
Commits on Source (28)
Showing
with 424 additions and 126 deletions
image: "registry.gitlab.syncad.com/hive/hive/ci-base-image:ubuntu22.04-3"
stages:
- static_code_analysis
- build
......@@ -14,18 +12,32 @@ workflow:
- if: $CI_COMMIT_BRANCH
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
PACKAGES_TO_CHECK: "clive/ tests/"
# colors:
TXT_BLUE: "\e[1;34m"
TXT_CLEAR: "\e[0m"
BEEKEEPER_BINARY: "$CI_PROJECT_DIR/beekeeper"
HIVE_BUILD_ROOT_PATH: "$CI_PROJECT_DIR/hived"
HIVE_BUILD_ROOT_PATH: "hived-binaries"
BEEKEEPER_BINARY: "${HIVE_BUILD_ROOT_PATH}/mainnet/beekeeper"
# uses registry.gitlab.syncad.com/hive/hive/ci-base-image:ubuntu22.04-5
TEST_IMAGE_TAG: "@sha256:eaa6f32730f0f4c45a95a65b6d790bea2b71a59276eb28795c04be7703f003e6"
CI_BASE_IMAGE: "registry.gitlab.syncad.com/hive/hive/ci-base-image${TEST_IMAGE_TAG}"
include:
- project: 'hive/hive'
ref: fc899116bf691309cc618e51a9c2d8c6d5edb8cd #develop
file: '/scripts/ci-helpers/prepare_data_image_job.yml'
image: ${CI_BASE_IMAGE}
.shared_tags: &shared_tags
- hived-for-tests
- public-runner-docker
.configuration:
interruptible: true
before_script: &configuration_before_script # configure python
- python3 -V
- poetry self update
......@@ -71,37 +83,27 @@ type_check_with_mypy:
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| BUILD |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.hive_based_build:
.common_prepare_hived_image:
extends: .prepare_hived_image
stage: build
needs: []
variables:
TARGET: ""
SOURCE: ""
DESTINATION: ""
script:
- cd hive
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_HIVE_TESTNET=ON -GNinja ..
- ninja $TARGET
- cp -r $SOURCE $DESTINATION
artifacts:
paths:
- $DESTINATION
tags: *shared_tags
build_beekeeper:
extends: .hive_based_build
REGISTRY_USER: "$HIVED_CI_IMGBUILDER_USER"
REGISTRY_PASS: $HIVED_CI_IMGBUILDER_PASSWORD
SUBMODULE_DIR: "${CI_PROJECT_DIR}/hive/"
BINARY_CACHE_PATH: "${HIVE_BUILD_ROOT_PATH}/${HIVE_NETWORK_TYPE}"
tags:
- public-runner-docker
- hived-for-tests
prepare_mainnet_hived_image:
extends: .common_prepare_hived_image
variables:
TARGET: "beekeeper"
SOURCE: "programs/beekeeper/beekeeper"
DESTINATION: "$BEEKEEPER_BINARY"
HIVE_NETWORK_TYPE: mainnet
build_hived:
extends: .hive_based_build
prepare_testnet_hived_image:
extends: .common_prepare_hived_image
variables:
TARGET: "hived"
SOURCE: "."
DESTINATION: "$HIVE_BUILD_ROOT_PATH"
HIVE_NETWORK_TYPE: testnet
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| BUILD |<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
......@@ -111,12 +113,13 @@ build_hived:
stage: tests
extends: .configuration
needs:
- job: build_beekeeper
- job: prepare_mainnet_hived_image
artifacts: true
- job: build_hived
- job: prepare_testnet_hived_image
artifacts: true
variables:
CLIVE_BEEKEEPER__PATH: $BEEKEEPER_BINARY
HIVED_PATH: "${CI_PROJECT_DIR}/${HIVE_BUILD_ROOT_PATH}/testnet/hived"
PATH_TO_REPORT: "$CI_PROJECT_DIR/report.xml"
artifacts:
reports:
......@@ -138,56 +141,82 @@ testing_clive:
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| BUILD DOCKER |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.build_and_push_base:
image: docker:20.10.13
.prepare_clive_image:
extends: .docker_image_builder_job
stage: build_docker
needs:
- job: pre_commit_checks
- job: build_beekeeper
- job: prepare_mainnet_hived_image
artifacts: true
- job: testing_clive
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME$BUILD_SUFFIX:$CI_COMMIT_SHORT_SHA
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME$BUILD_SUFFIX:latest
services:
- docker:20.10.13-dind
before_script:
- ls -la
- cd docker/
- echo -e "${TXT_BLUE}Building a docker image started...${TXT_CLEAR}"
BASE_IMAGE: ""
BUILD_INSTANCE_ARGS: ""
TAG_COMMIT: ${BUILD_SUFFIX}${CI_COMMIT_SHORT_SHA}
SCRIPTS_PATH: "$CI_PROJECT_DIR/scripts"
script:
- $SCRIPTS_PATH/ci-helpers/build_instance.sh "${TAG_COMMIT}" "${CI_PROJECT_DIR}" $CI_REGISTRY_IMAGE --beekeeper-source-image=${HIVED_IMAGE_NAME} --base-image=${BASE_IMAGE} ${BUILD_INSTANCE_ARGS}
- echo $CI_BUILD_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
after_script:
- docker push $TAG_COMMIT
- docker push $TAG_LATEST
- source docker_image_name.env
- docker push ${CLIVE_IMAGE_NAME}
artifacts:
reports:
dotenv: docker_image_name.env
paths:
- ./docker_image_name.env
expire_in: 6 hours
tags: *shared_tags
build_and_push_docker_image:
extends: .build_and_push_base
build_and_push_clive_image:
extends: .prepare_clive_image
variables:
BASE_IMAGE: ${CI_BASE_IMAGE}
build_and_push_clive_testnet_image:
extends: .prepare_clive_image
needs:
- job: prepare_testnet_hived_image
artifacts: true
variables:
BASE_IMAGE: ${HIVED_IMAGE_NAME}
BUILD_INSTANCE_ARGS: "--embedded-testnet"
build_and_push_clive_stable_image:
stage: build_docker
needs:
- job: build_and_push_clive_image
artifacts: true
only:
- develop
- master
variables:
ADDITIONAL_IMAGE_NAME: ${CLIVE_IMAGE_PATH}${CLIVE_IMAGE_TAG_PREFIX}${CI_COMMIT_REF_NAME}
script:
- docker build -t $TAG_COMMIT -t $TAG_LATEST -f Dockerfile ..
- docker image tag ${CLIVE_IMAGE_NAME} ${ADDITIONAL_IMAGE_NAME}
- echo $CI_BUILD_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker push ${ADDITIONAL_IMAGE_NAME}
build_and_push_docker_testnet_image:
extends: .build_and_push_base
build_and_push_clive_stable_testnet_image:
stage: build_docker
needs:
- job: pre_commit_checks
- job: testing_clive
- job: build_beekeeper
artifacts: true
- job: build_hived
- job: build_and_push_clive_testnet_image
artifacts: true
rules:
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_REF_NAME != "develop"'
when: manual
- when: always
allow_failure: true
only:
- develop
- master
variables:
BUILD_SUFFIX: "-testnet"
ADDITIONAL_IMAGE_NAME: ${CLIVE_IMAGE_PATH}${CLIVE_IMAGE_TAG_PREFIX}${CI_COMMIT_REF_NAME}
script:
- docker build -t $TAG_COMMIT -t $TAG_LATEST -f Dockerfile.TESTNET ..
- docker image tag ${CLIVE_IMAGE_NAME} ${ADDITIONAL_IMAGE_NAME}
- echo $CI_BUILD_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker push ${ADDITIONAL_IMAGE_NAME}
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| BUILD DOCKER |<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
......@@ -122,6 +122,8 @@ class Beekeeper:
if self.__notification_server.opening_beekeeper_failed.wait(timeout):
self.__close_beekeeper()
self.__notification_server_port = self.__notification_server.listen()
self.config.notifications_endpoint = Url("http", "127.0.0.1", self.__notification_server_port)
elif not (
self.__notification_server.http_listening_event.wait(timeout)
and self.__notification_server.ready.wait(timeout)
......
......@@ -6,7 +6,7 @@ from http import HTTPStatus
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import TYPE_CHECKING, Any, Protocol, cast
from clive.__private.core.beekeeper.raise_exception_helper import RaiseExceptionHelper
from clive.__private.core.raise_exception_helper import RaiseExceptionHelper
if TYPE_CHECKING:
from collections.abc import Callable
......
......@@ -23,7 +23,7 @@ class BeekeeperNotificationsServer:
def notify(self, message: JsonT) -> None:
logger.info(f"Got notification: {message}")
details: dict[str, str] = message["value"]
details = message["value"]
if message["name"] == "webserver listening":
if details["type"] == "HTTP":
self.http_endpoint = self.__parse_endpoint_notification(details)
......@@ -33,6 +33,7 @@ class BeekeeperNotificationsServer:
logger.debug("Beekeeper reports to be ready")
self.ready.set()
elif message["name"] == "opening_beekeeper_failed":
details = details["connection"]
assert details["type"] == "HTTP"
self.http_endpoint = self.__parse_endpoint_notification(details)
logger.debug(f"Got notification with http address, but beekeeper failed when opening: {self.http_endpoint}")
......
from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from math import ceil
from typing import TYPE_CHECKING, Final, cast
......@@ -90,7 +90,9 @@ class UpdateNodeData(Command):
account.data.last_refresh = self.__normalize_datetime(datetime.utcnow())
def __harvest_data_from_api(self) -> dict[Account, AccountApiInfo]:
account_names = [acc.name for acc in self.accounts]
account_names = [acc.name for acc in self.accounts if acc.name]
if not account_names:
return {}
core_accounts_info: dict[str, AccountItemFundament[Asset.Hive, Asset.Hbd, Asset.Vests]] = {
str(acc.name): acc for acc in self.node.api.database_api.find_accounts(accounts=account_names).accounts
}
......@@ -112,9 +114,7 @@ class UpdateNodeData(Command):
)
info.warnings = self.__count_warning(account, info)
with SuppressNotExistingApi("account_history_api"):
info.latest_interaction = self.__normalize_datetime(
self.__get_newest_account_interactions(account.name)
)
info.latest_interaction = self.__get_newest_account_interactions(account.name)
result[account] = info
return result
......@@ -160,12 +160,13 @@ class UpdateNodeData(Command):
assert account_info.core is not None, "account_info.core cannot be None"
warning_period_in_days: Final[int] = 31
return int(
account_info.core.governance_vote_expiration_ts - timedelta(days=warning_period_in_days) > datetime.utcnow()
account_info.core.governance_vote_expiration_ts - timedelta(days=warning_period_in_days)
> self.__normalize_datetime(datetime.utcnow())
)
def __get_newest_account_interactions(self, account_name: str) -> datetime:
non_virtual_operations_filter: Final[int] = 0x3FFFFFFFFFFFF
return (
return self.__normalize_datetime(
self.node.api.account_history_api.get_account_history(
account=account_name,
limit=1,
......@@ -238,4 +239,4 @@ class UpdateNodeData(Command):
)
def __normalize_datetime(self, date: datetime) -> datetime:
return date.replace(microsecond=0)
return date.replace(microsecond=0, tzinfo=timezone.utc)
......@@ -68,7 +68,7 @@ def calculate_manabar_full_regeneration_time(
now=now, max_mana=max_mana, current_mana=current_mana, last_update_time=last_update_time
)
__validate_wax_response(result)
return datetime.datetime.utcfromtimestamp(int(result.result.decode()))
return datetime.datetime.utcfromtimestamp(int(result.result.decode())).replace(tzinfo=datetime.timezone.utc)
def calculate_current_manabar_value(now: int, max_mana: int, current_mana: int, last_update_time: int) -> int:
......
......@@ -12,6 +12,7 @@ from textual.reactive import reactive, var
from clive.__private.config import settings
from clive.__private.core.communication import Communication
from clive.__private.core.profile_data import ProfileData
from clive.__private.core.raise_exception_helper import RaiseExceptionHelper
from clive.__private.core.world import TextualWorld
from clive.__private.logger import logger
from clive.__private.ui.activate.activate import Activate as ActivateScreen
......@@ -98,6 +99,7 @@ class Clive(App[int], ManualReactive):
def on_mount(self) -> None:
refresh_interval: Final[int] = 3
self.console.set_window_title("Clive")
RaiseExceptionHelper.initialize()
def update_data_worker(closed: ThreadPoolClosedCallbackT) -> None:
while not closed():
......@@ -294,9 +296,12 @@ class Clive(App[int], ManualReactive):
self.post_message(BackgroundErrorOccurred(error))
def __update_data_from_node(self) -> None:
self.world.commands.update_node_data(
accounts=[self.world.profile_data.working_account, *self.world.profile_data.watched_accounts]
)
try:
self.world.commands.update_node_data(
accounts=[self.world.profile_data.working_account, *self.world.profile_data.watched_accounts]
)
except Exception as e: # noqa: BLE001
RaiseExceptionHelper.raise_exception_in_main_thread(e)
async def __debug_log(self) -> None:
logger.debug("===================== DEBUG =====================")
......
from __future__ import annotations
import re
from typing import TYPE_CHECKING, Final
import humanize
......@@ -20,6 +21,7 @@ from clive.models import Asset
if TYPE_CHECKING:
from collections.abc import Callable
from datetime import datetime
from textual.app import ComposeResult
......@@ -73,8 +75,10 @@ class ManabarRepresentation(AccountReferencingWidget, CliveWidget):
)
def __pretty_hivepower(self) -> str:
formated_size = humanize.naturalsize(self.__manabar.value, binary=False)
return formated_size.replace(" Bytes", "").upper().replace(" ", "") + " HP"
format_fix_regex = re.compile(r"(\d+\.\d*) (.)B")
matched = format_fix_regex.match(humanize.naturalsize(self.__manabar.value, binary=False))
assert matched is not None
return f"{matched[1]}{matched[2]} HP".upper()
class BalanceStats(AccountReferencingWidget):
......@@ -117,9 +121,19 @@ class AccountInfo(Container, AccountReferencingWidget):
yield Static()
yield Label("LAST:")
yield DynamicLabel(
self.app.world, "profile_data", lambda _: f"Transaction: {self._account.data.last_transaction}"
self.app.world,
"profile_data",
lambda _: f"Transaction: {self.__humanize_datetime(self._account.data.last_transaction)}",
)
yield DynamicLabel(self.app.world, "profile_data", lambda _: f"Update: {self._account.data.last_refresh}")
yield DynamicLabel(
self.app.world,
"profile_data",
lambda _: f"Update: {self.__humanize_datetime(self._account.data.last_refresh)}",
)
@classmethod
def __humanize_datetime(cls, dt: datetime) -> str:
return dt.replace(tzinfo=None).isoformat()
class AccountRow(AccountReferencingWidget):
......
FROM registry.gitlab.syncad.com/hive/hive/ci-base-image:ubuntu22.04-3
ARG BEEKEEPER_IMAGE
ARG BASE_IMAGE
ARG CI_REGISTRY_IMAGE=registry.gitlab.syncad.com/hive/clive/
FROM $BEEKEEPER_IMAGE as beekeper_source
FROM $BASE_IMAGE AS instance
SHELL ["/bin/bash", "-c"]
ADD --chown=hived_admin:users . /clive
WORKDIR /clive
ARG BEEKEEPER_LOCATION="./beekeeper"
ENV BEEKEEPER_PATH="/clive/beekeeper"
ADD --chown=hived_admin:users "${BEEKEEPER_LOCATION}" "${BEEKEEPER_PATH}"
RUN poetry self update
COPY --from=beekeper_source --chown=hived_admin:users "/home/hived/bin/beekeeper" "${BEEKEEPER_PATH}"
RUN poetry install --only main
RUN poetry self update && \
poetry install --only main
# crucial for proper display
ENV COLORTERM=truecolor
ENTRYPOINT ["poetry", "run", "clive"]
# this target should be built using a testnet hived image as a base (to have embedded testnet)
FROM instance as embedded_testnet_instance
ARG CLIVE_SECRETS__DEFAULT_KEY="5KTNAYSHVzhnVPrwHpKhc5QqNQt6aW8JsrMT7T4hyrKydzYvYik"
ENV CLIVE_SECRETS__DEFAULT_KEY=${CLIVE_SECRETS__DEFAULT_KEY}
ENV HIVED_PATH="/home/hived/bin/hived"
ENV CLI_WALLET_PATH="/home/hived/bin/cli_wallet"
ENV GET_DEV_KEY_PATH="/home/hived/bin/get_dev_key"
ENV COMPRESS_BLOCK_LOG_PATH="/home/hived/bin/compress_block_log"
WORKDIR /clive
# Run installation once again to supplement extras and development dependencies
RUN poetry install
ENTRYPOINT ["poetry", "run", "python", "testnet_node.py"]
FROM registry.gitlab.syncad.com/hive/hive/ci-base-image:ubuntu22.04-3
ADD --chown=hived_admin:users . /clive
WORKDIR /clive
ARG HIVE_BUILD_ROOT_LOCATION="./hived/"
ENV HIVE_BUILD_ROOT_PATH="/clive/hived/"
ADD --chown=hived_admin:users "${HIVE_BUILD_ROOT_LOCATION}" "${HIVE_BUILD_ROOT_PATH}"
ARG BEEKEEPER_LOCATION="./beekeeper"
ENV BEEKEEPER_PATH="/clive/beekeeper"
ADD --chown=hived_admin:users "${BEEKEEPER_LOCATION}" "${BEEKEEPER_PATH}"
RUN poetry self update
RUN poetry install
# crucial for proper display
ENV COLORTERM=truecolor
ENV CLIVE_BEEKEEPER__PATH="${BEEKEEPER_PATH}"
ENV CLIVE_SECRETS__DEFAULT_KEY="5KTNAYSHVzhnVPrwHpKhc5QqNQt6aW8JsrMT7T4hyrKydzYvYik"
ENTRYPOINT bash docker/entrypoint-testnet.bash
#!/bin/bash
poetry run python testnet_node.py &
sleep 15
poetry run clive
Subproject commit 806e1d37bcf912a2e4d6bb0114492b59c3f03e98
Subproject commit dd58c759ad1953df8910eb48c25998f220dcea08
#! /bin/bash
set -euo pipefail
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SCRIPTSDIR="$SCRIPTPATH/.."
LOG_FILE=build_instance.log
source "$SCRIPTSDIR/common.sh"
BUILD_IMAGE_TAG=""
REGISTRY=""
SRCROOTDIR=""
IMAGE_TAG_PREFIX=""
BEEKEEPER_IMAGE=""
BASE_IMAGE=""
DOCKER_TARGET="instance"
print_help () {
echo "Usage: $0 <image_tag> <src_dir> <registry_url> [OPTION[=VALUE]]..."
echo
echo "Allows to build docker image containing clive installation"
echo "OPTIONS:"
echo " --beekeeper-source-image=image_name Allows to specify image name containing a prebuilt beekeper tool"
echo " --base-image=image_name Allows to specify an image name being use as a base of the one to be built"
echo " --embedded-testnet Allows to build a clive image having embedded a hived testnet inside (ready for immediate sanboxing run)"
echo " --help Display this help screen and exit"
echo
}
EXPORT_PATH=""
while [ $# -gt 0 ]; do
case "$1" in
--beekeeper-source-image=*)
BEEKEEPER_IMAGE="${1#*=}"
;;
--base-image=*)
BASE_IMAGE="${1#*=}"
;;
--embedded-testnet)
DOCKER_TARGET="embedded_testnet_instance"
IMAGE_TAG_PREFIX="testnet-"
;;
--help)
print_help
exit 0
;;
*)
if [ -z "$BUILD_IMAGE_TAG" ];
then
BUILD_IMAGE_TAG="${1}"
elif [ -z "$SRCROOTDIR" ];
then
SRCROOTDIR="${1}"
elif [ -z "$REGISTRY" ];
then
REGISTRY=${1}
else
echo "ERROR: '$1' is not a valid option/positional argument"
echo
print_help
exit 2
fi
;;
esac
shift
done
TST_IMGTAG=${BUILD_IMAGE_TAG:?"Missing arg #1 to specify built image tag"}
TST_SRCDIR=${SRCROOTDIR:?"Missing arg #2 to specify source directory"}
TST_REGISTRY=${REGISTRY:?"Missing arg #3 to specify target container registry"}
TST_BEEKEEPER_IMAGE=${BEEKEEPER_IMAGE:?"Missing --beekeeper-source-image to specify beekeeper binary source"}
TST_BASE_IMAGE=${BASE_IMAGE:?"Missing --base-image option to specify base image"}
# Supplement a registry path by trailing slash (if needed)
[[ "${REGISTRY}" != */ ]] && REGISTRY="${REGISTRY}/"
echo "Moving into source root directory: ${SRCROOTDIR}"
pushd "$SRCROOTDIR"
export DOCKER_BUILDKIT=1
docker build --target=${DOCKER_TARGET} \
--build-arg CI_REGISTRY_IMAGE=$REGISTRY \
--build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg BEEKEEPER_IMAGE=${BEEKEEPER_IMAGE} \
-t ${REGISTRY}${IMAGE_TAG_PREFIX}instance:${IMAGE_TAG_PREFIX}instance-${BUILD_IMAGE_TAG} \
-f docker/Dockerfile .
popd
echo "CLIVE_IMAGE_NAME=${REGISTRY}${IMAGE_TAG_PREFIX}instance:${IMAGE_TAG_PREFIX}instance-${BUILD_IMAGE_TAG}" > docker_image_name.env
echo "CLIVE_IMAGE_PATH=${REGISTRY}${IMAGE_TAG_PREFIX}instance" >> docker_image_name.env
echo "CLIVE_IMAGE_TAG_PREFIX=:${IMAGE_TAG_PREFIX}instance-" >> docker_image_name.env
#! /bin/bash
set -euo pipefail
exec > >(tee -i "${LOG_FILE}") 2>&1
log_exec_params() {
echo
echo -n "$0 parameters: "
for arg in "$@"; do echo -n "$arg "; done
echo
}
do_clone_commit() {
local commit="$1"
local src_dir=$2
local repo_url=$3
echo "Cloning commit: $commit from $repo_url into: $src_dir ..."
mkdir -p "$src_dir"
pushd "$src_dir"
git init
git remote add origin "$repo_url"
git fetch --depth 1 origin "$commit"
git checkout FETCH_HEAD
git submodule update --init --recursive
popd
}
do_clone_branch() {
local branch=$1
local src_dir="$2"
local repo_url="$3"
echo "Cloning branch: $branch from $repo_url ..."
git clone --recurse-submodules --shallow-submodules --single-branch --depth=1 --branch "$branch" -- "$repo_url" "$src_dir"
}
do_clone() {
local branch=$1
local src_dir="$2"
local repo_url="$3"
local commit="$4"
if [[ "$commit" != "" ]]; then
do_clone_commit $commit "$src_dir" $repo_url
else
do_clone_branch "$branch" "$src_dir" $repo_url
fi
}
#! /bin/bash
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
echo "$SCRIPTPATH"
LOG_FILE=run_instance.log
source "$SCRIPTPATH/common.sh"
log_exec_params "$@"
# Script reponsible for starting a docker container built for image specified at command line.
print_help () {
echo "Usage: $0 <docker_img> [OPTION[=VALUE]]... [<hived_option>]..."
echo
echo "Allows to start docker container for a pointed clive docker image."
echo "OPTIONS:"
echo " --name=CONTAINER_NAME Allows to specify a dedicated name to the spawned container instance"
echo " --detach Allows to start container instance in detached mode. Otherwise, you can detach using Ctrl+p+q key binding"
echo " --docker-option=OPTION Allows to specify additional docker option, to be passed to underlying docker run spawn."
echo " --help Display this help screen and exit"
echo
}
DOCKER_ARGS=()
CLIVE_ARGS=()
CONTAINER_NAME=clive-instance
IMAGE_NAME=
add_docker_arg() {
local arg="$1"
# echo "Processing docker argument: ${arg}"
DOCKER_ARGS+=("$arg")
}
add_clive_arg() {
local arg="$1"
# echo "Processing hived argument: ${arg}"
CLIVE_ARGS+=("$arg")
}
while [ $# -gt 0 ]; do
case "$1" in
--name=*)
CONTAINER_NAME="${1#*=}"
echo "Container name is: $CONTAINER_NAME"
;;
--detach)
add_docker_arg "--detach"
;;
--docker-option=*)
option="${1#*=}"
add_docker_arg "$option"
;;
--help)
print_help
exit 0
;;
-*)
add_clive_arg "$1"
;;
*)
IMAGE_NAME="${1}"
echo "Using image name: $IMAGE_NAME"
;;
esac
shift
done
# Collect remaining command line args to pass to the container to run
CMD_ARGS=("$@")
if [ -z "$IMAGE_NAME" ]; then
echo "Error: Missing docker image name."
echo "Usage: $0 <docker_img> [OPTION[=VALUE]]... [<hived_option>]..."
echo
exit 1
fi
CMD_ARGS+=("${CLIVE_ARGS[@]}")
#echo "Using docker image: $IMAGE_NAME"
#echo "Additional hived args: ${CMD_ARGS[@]}"
docker container rm -f -v "$CONTAINER_NAME" 2>/dev/null || true
docker run --rm -it -e HIVED_UID=$(id -u) -e COLUMNS=$(tput cols) -e LINES=$(tput lines) --name "$CONTAINER_NAME" --stop-timeout=180 ${DOCKER_ARGS[@]} "${IMAGE_NAME}" "${CMD_ARGS[@]}"
from __future__ import annotations
import sys
import time
from random import randint
from typing import TYPE_CHECKING
import test_tools as tt
from clive.main import main as clive_main
ARGS_COUNT = 2
if TYPE_CHECKING:
from typing import Any
......@@ -53,7 +58,12 @@ tt.logger.info(f"{alice.name} public key: {alice.public_key}")
tt.logger.info(f"{alice.name} private key: {alice.private_key}")
tt.logger.info("done!")
tt.logger.info("serving forever... press Ctrl+C to exit")
# passing any argument to the script will skip clive autolaunch i.e. for debugging purposes.
if len(sys.argv) < ARGS_COUNT:
tt.logger.info("Attempting to start a clive interactive mode - exit to finish")
clive_main()
else:
tt.logger.info("serving forever... press Ctrl+C to exit")
while True:
time.sleep(1)
while True:
time.sleep(1)