mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
Modifies ConfigParser so config file is passed as parameter (to be used by both teos and cli)
- Modifies ConfigParser - Adapts __init__ and teosd at teos/
This commit is contained in:
14
cli/conf.py
14
cli/conf.py
@@ -1,14 +0,0 @@
|
||||
# TEOS-SERVER
|
||||
DEFAULT_TEOS_API_SERVER = "http://localhost"
|
||||
DEFAULT_TEOS_API_PORT = 9814
|
||||
|
||||
# WT-CLI
|
||||
DATA_FOLDER = "~/.teos_cli/"
|
||||
|
||||
CLIENT_LOG_FILE = "cli.log"
|
||||
APPOINTMENTS_FOLDER_NAME = "appointment_receipts"
|
||||
|
||||
# KEYS
|
||||
TEOS_PUBLIC_KEY = "teos_pk.der"
|
||||
CLI_PRIVATE_KEY = "cli_sk.der"
|
||||
CLI_PUBLIC_KEY = "cli_pk.der"
|
||||
@@ -28,9 +28,9 @@ class ConfigLoader:
|
||||
ones in default / config file.
|
||||
"""
|
||||
|
||||
def __init__(self, data_dir, default_conf, command_line_conf):
|
||||
def __init__(self, data_dir, conf_file_name, default_conf, command_line_conf):
|
||||
self.data_dir = data_dir
|
||||
self.conf_file_path = self.data_dir + "teos.conf"
|
||||
self.conf_file_path = self.data_dir + conf_file_name
|
||||
self.conf_fields = default_conf
|
||||
self.command_line_conf = command_line_conf
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from teos.utils.auth_proxy import AuthServiceProxy
|
||||
HOST = "localhost"
|
||||
PORT = 9814
|
||||
DATA_DIR = os.path.expanduser("~/.teos/")
|
||||
CONF_FILE_NAME = "teos.conf"
|
||||
LOG_PREFIX = "teos"
|
||||
|
||||
# Default conf fields
|
||||
|
||||
@@ -9,7 +9,6 @@ from common.config_loader import ConfigLoader
|
||||
from common.cryptographer import Cryptographer
|
||||
from common.tools import setup_logging, setup_data_folder
|
||||
|
||||
from teos import LOG_PREFIX, DATA_DIR, DEFAULT_CONF
|
||||
from teos.api import API
|
||||
from teos.watcher import Watcher
|
||||
from teos.builder import Builder
|
||||
@@ -20,6 +19,7 @@ from teos.db_manager import DBManager
|
||||
from teos.chain_monitor import ChainMonitor
|
||||
from teos.block_processor import BlockProcessor
|
||||
from teos.tools import can_connect_to_bitcoind, in_correct_network
|
||||
from teos import LOG_PREFIX, DATA_DIR, DEFAULT_CONF, CONF_FILE_NAME
|
||||
|
||||
logger = Logger(actor="Daemon", log_name_prefix=LOG_PREFIX)
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
@@ -42,7 +42,7 @@ def main():
|
||||
signal(SIGQUIT, handle_signals)
|
||||
|
||||
# Loads config and sets up the data folder and log file
|
||||
config_loader = ConfigLoader(DATA_DIR, DEFAULT_CONF, command_line_conf)
|
||||
config_loader = ConfigLoader(DATA_DIR, CONF_FILE_NAME, DEFAULT_CONF, command_line_conf)
|
||||
config = config_loader.build_config()
|
||||
setup_data_folder(DATA_DIR)
|
||||
setup_logging(config.get("LOG_FILE"), LOG_PREFIX)
|
||||
|
||||
@@ -169,7 +169,7 @@ def generate_dummy_tracker():
|
||||
|
||||
|
||||
def get_config():
|
||||
config_loader = ConfigLoader(".", DEFAULT_CONF, {})
|
||||
config_loader = ConfigLoader(".", "teos.conf", DEFAULT_CONF, {})
|
||||
config = config_loader.build_config()
|
||||
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user