Skip to content

Commit

Permalink
Merge pull request #71 from skalenetwork/develop
Browse files Browse the repository at this point in the history
New beta version
  • Loading branch information
dmytrotkk authored Nov 7, 2019
2 parents 608bfaa + 66db37d commit 2e4d70e
Show file tree
Hide file tree
Showing 38 changed files with 1,092 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 100
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
language: python
python:
- '3.6'
os: linux
dist: bionic
python: '3.6'
cache: pip
install:
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
before_script:
- "flake8 ."
- pip install -e .
- pip install -e .[dev]
- export ENV=dev
- bash scripts/build.sh 1.0.0 test-branch
jobs:
include:
#- stage: test
- stage: test
before_script:
- flake8 .
script:
- bash scripts/run-tests.sh
- stage: deploy
if: branch IN (develop, beta, stable, master)
script:
Expand Down Expand Up @@ -60,4 +65,4 @@ jobs:
- master
- stable
- develop
- beta
- beta
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased


### Added


### Changed

- `--dkg-url` option for `node init` and `node update` commands removed



## [0.4.0] - 2019-10-03

Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @dmitry-tk @kladkogex
2 changes: 1 addition & 1 deletion cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.5.0'
__version__ = '0.6.0'

if __name__ == "__main__":
print(__version__)
12 changes: 6 additions & 6 deletions cli/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ def metrics():
@login_required
def first():
print('Please wait - collecting metrics from blockchain...')
bounty_list = get('first-bounties')
if not bounty_list:
bounty_data = get('first-bounties')
if not bounty_data.get('bounties'):
print('No bounties found')
return
print_metrics(bounty_list)
print_metrics(bounty_data)


@metrics.command(help="List of bounties and metrics for the last year")
@login_required
def last():
print('Please wait - collecting metrics from blockchain...')
bounty_list = get('last-bounties')
if not bounty_list:
bounty_data = get('last-bounties')
if not bounty_data.get('bounties'):
print('No bounties found')
return
print_metrics(bounty_list)
print_metrics(bounty_data)
34 changes: 12 additions & 22 deletions cli/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from urllib.parse import urlparse

import click
from readsettings import ReadSettings

from skale.utils.random_names.generator import generate_random_node_name

Expand All @@ -30,10 +29,11 @@
from core.host import install_host_dependencies
from core.helper import (abort_if_false, local_only,
login_required, safe_load_texts)
from core.config import CONFIG_FILEPATH, DEFAULT_DB_USER, DEFAULT_DB_PORT
from configs.node import DEFAULT_NODE_BASE_PORT
from configs import DEFAULT_DB_USER, DEFAULT_DB_PORT, DEFAULT_NODE_BASE_PORT
from tools.helper import session_config

config = ReadSettings(CONFIG_FILEPATH)

config = session_config()
TEXTS = safe_load_texts()


Expand Down Expand Up @@ -81,13 +81,15 @@ def node():
@click.option('--format', '-f', type=click.Choice(['json', 'text']))
@login_required
def node_info(format):
config = session_config()
get_node_info(config, format)


@node.command('about', help="Get service info about SKALE node")
@click.option('--format', '-f', type=click.Choice(['json', 'text']))
@login_required
def node_about(format):
config = session_config()
get_node_about(config, format)


Expand Down Expand Up @@ -124,6 +126,7 @@ def node_about(format):
@login_required
# def register_node(name, p2p_ip, public_ip, port):
def register_node(name, ip, port):
config = session_config()
create_node(config, name, ip, ip, port)


Expand Down Expand Up @@ -200,11 +203,6 @@ def register_node(name, ip, port):
prompt="Enter URL to IMA contracts ABI and addresses",
help='URL to IMA contracts ABI and addresses'
)
@click.option(
'--dkg-url',
prompt="Enter URL to DKG contracts ABI and addresses",
help='URL to DKG contracts ABI and addresses'
)
@click.option(
'--filebeat-url',
prompt="Enter URL to the Filebeat log server",
Expand All @@ -217,16 +215,14 @@ def register_node(name, ip, port):
@local_only
def init_node(ima_endpoint, install_deps, stream, github_token, docker_username, docker_password,
endpoint, db_user, db_password, db_root_password, db_port, disk_mountpoint,
manager_url, ima_url, dkg_url, filebeat_url, test_mode):
manager_url, ima_url, filebeat_url, test_mode):
if install_deps:
install_host_dependencies()
if not db_root_password:
db_root_password = db_password

git_branch = stream
init(ima_endpoint, git_branch, github_token, docker_username, docker_password, endpoint,
init(ima_endpoint, stream, github_token, docker_username, docker_password, endpoint,
db_user, db_password, db_root_password, db_port, disk_mountpoint, manager_url, ima_url,
dkg_url, filebeat_url, test_mode)
filebeat_url, test_mode)


@node.command('purge', help="Uninstall SKALE node software from the machine")
Expand Down Expand Up @@ -312,21 +308,15 @@ def purge_node():
prompt="Enter URL to IMA contracts ABI and addresses",
help='URL to IMA contracts ABI and addresses'
)
@click.option(
'--dkg-url',
prompt="Enter URL to DKG contracts ABI and addresses",
help='URL to DKG contracts ABI and addresses'
)
@click.option(
'--filebeat-url',
prompt="Enter URL to the Filebeat log server",
help='URL to the Filebeat log server'
)
@local_only
def update_node(ima_endpoint, github_token, docker_username, docker_password, endpoint, db_user,
db_password, db_root_password, db_port, manager_url, ima_url, dkg_url,
filebeat_url):
db_password, db_root_password, db_port, manager_url, ima_url, filebeat_url):
if not db_root_password:
db_root_password = db_password
update(ima_endpoint, github_token, docker_username, docker_password, endpoint, db_user,
db_password, db_root_password, db_port, manager_url, ima_url, dkg_url, filebeat_url)
db_password, db_root_password, db_port, manager_url, ima_url, filebeat_url)
71 changes: 71 additions & 0 deletions configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
#
# This file is part of skale-node-cli
#
# Copyright (C) 2019 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 General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
import sys
import platform
from pathlib import Path
from configs.routes import ROUTES # noqa: F401

HOME_DIR = str(Path.home())
SKALE_DIR = os.path.join(HOME_DIR, '.skale')

PROJECT_PATH = os.path.join(SKALE_DIR, '.skale-node')
NODE_DATA_PATH = os.path.join(SKALE_DIR, 'node_data')
CONFIG_FILEPATH = os.environ.get('CONFIG_FILEPATH') or \
os.path.join(SKALE_DIR, '.skale-cli.yaml')

TOKENS_FILEPATH = os.path.join(NODE_DATA_PATH, 'tokens.json')
LOCAL_WALLET_FILEPATH = os.path.join(NODE_DATA_PATH, 'local_wallet.json')

UNINSTALL_SCRIPT = os.path.join(PROJECT_PATH, 'scripts', 'uninstall.sh')
UPDATE_SCRIPT = os.path.join(PROJECT_PATH, 'scripts', 'update.sh')


ENV = os.environ.get('ENV')
CURRENT_FILE_LOCATION = os.path.dirname(os.path.realpath(__file__))

if ENV == 'dev':
PARDIR = os.path.join(CURRENT_FILE_LOCATION, os.pardir)
else:
PARDIR = os.path.join(sys._MEIPASS, 'data')

TEXT_FILE = os.path.join(PARDIR, 'text.yml')
DATAFILES_FOLDER = os.path.join(PARDIR, 'datafiles')

THIRDPARTY_FOLDER_PATH = os.path.join(DATAFILES_FOLDER, 'third_party')

DEPENDENCIES_SCRIPT = os.path.join(DATAFILES_FOLDER, 'dependencies.sh')
INSTALL_SCRIPT = os.path.join(DATAFILES_FOLDER, 'install.sh')
INSTALL_CONVOY_SCRIPT = os.path.join(DATAFILES_FOLDER, 'install_convoy.sh')
UPDATE_NODE_PROJECT_SCRIPT = os.path.join(DATAFILES_FOLDER, 'update_node_project.sh')

LONG_LINE = '-' * 50

SKALE_NODE_UI_PORT = 3007
SKALE_NODE_UI_LOCALHOST = 'http://0.0.0.0'
DEFAULT_URL_SCHEME = 'http://'

DEFAULT_DB_USER = 'root'
DEFAULT_DB_PORT = '3306'

DEFAULT_NODE_BASE_PORT = 10000

HOST_OS = platform.system()
MAC_OS_SYSTEM_NAME = 'Darwin'
11 changes: 4 additions & 7 deletions configs/cli_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
from configs.node import HOME_DIR
from configs import SKALE_DIR

LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

LOG_FILE_SIZE_MB = 300
LOG_FILE_SIZE_BYTES = LOG_FILE_SIZE_MB * 1000000

LOG_BACKUP_COUNT = 1
LOG_DATA_PATH = os.path.join(HOME_DIR, '.skale-cli-log')

LOG_FILENAME = 'node-cli.log'
DEBUG_LOG_FILENAME = 'debug-node-cli.log'
LOG_FILEPATH = os.path.join(LOG_DATA_PATH, LOG_FILENAME)
DEBUG_LOG_FILEPATH = os.path.join(LOG_DATA_PATH, DEBUG_LOG_FILENAME)
LOG_DATA_PATH = os.path.join(SKALE_DIR, '.skale-cli-log')
LOG_FILEPATH = os.path.join(LOG_DATA_PATH, 'node-cli.log')
DEBUG_LOG_FILEPATH = os.path.join(LOG_DATA_PATH, 'debug-node-cli.log')
3 changes: 1 addition & 2 deletions configs/resource_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
from configs.node import NODE_DATA_PATH
from core.config import THIRDPARTY_FOLDER_PATH, DATAFILES_FOLDER
from configs import NODE_DATA_PATH, THIRDPARTY_FOLDER_PATH, DATAFILES_FOLDER

MEDIUM_DIVIDER = 1
SMALL_DIVIDER = 8
Expand Down
21 changes: 21 additions & 0 deletions configs/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ROUTES = {
'login': '/login',
'logout': '/logout',
'register': '/join',
'node_info': '/node-info',
'node_about': '/about-node',
'create_node': '/create-node',
'test_host': '/test-host',

'wallet_info': '/load-wallet',
'validators_info': '/validators-info',

'schains_containers': '/containers/schains/list',
'node_schains': '/schains/list',
'schain_config': '/schain-config',
'skale_containers': '/containers/list',

'logs_dump': '/logs/dump',
'first-bounties': '/first-bounties',
'last-bounties': '/last-bounties'
}
Loading

0 comments on commit 2e4d70e

Please sign in to comment.