From b4126e664b51baf46ecc8316c08b97fd0134e0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 5 Dec 2022 12:28:26 +0100 Subject: [PATCH] nitpicks from vlad --- lnbits/app.py | 44 +++++++++++++++++++++++++------------------- lnbits/commands.py | 12 ++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lnbits/app.py b/lnbits/app.py index a94207aa..ed279af2 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -143,30 +143,36 @@ def register_startup(app: FastAPI): # 2. setup admin settings await check_admin_settings() - logger.info("Starting LNbits") - logger.info(f"Host: {settings.host}") - logger.info(f"Port: {settings.port}") - logger.info(f"Debug: {settings.debug}") - logger.info(f"Site title: {settings.lnbits_site_title}") - logger.info(f"Funding source: {settings.lnbits_backend_wallet_class}") - logger.info(f"Data folder: {settings.lnbits_data_folder}") - logger.info(f"Git version: {settings.lnbits_commit}") - - db_url = settings.lnbits_database_url - database = ( - "PostgreSQL" - if db_url and db_url.startswith("postgres://") - else "CockroachDB" - if db_url and db_url.startswith("cockroachdb://") - else "SQLite" - ) - logger.info(f"Database: {database}") - logger.info(f"Service fee: {settings.lnbits_service_fee}") + log_server_info() # 3. initialize funding source await check_funding_source() +def log_server_info(): + logger.info("Starting LNbits") + logger.info(f"Host: {settings.host}") + logger.info(f"Port: {settings.port}") + logger.info(f"Debug: {settings.debug}") + logger.info(f"Site title: {settings.lnbits_site_title}") + logger.info(f"Funding source: {settings.lnbits_backend_wallet_class}") + logger.info(f"Data folder: {settings.lnbits_data_folder}") + logger.info(f"Git version: {settings.lnbits_commit}") + logger.info(f"Database: {get_db_vendor_name()}") + logger.info(f"Service fee: {settings.lnbits_service_fee}") + + +def get_db_vendor_name(): + db_url = settings.lnbits_database_url + return ( + "PostgreSQL" + if db_url and db_url.startswith("postgres://") + else "CockroachDB" + if db_url and db_url.startswith("cockroachdb://") + else "SQLite" + ) + + def register_assets(app: FastAPI): """Serve each vendored asset separately or a bundle.""" diff --git a/lnbits/commands.py b/lnbits/commands.py index 1e663f1a..82ea1430 100644 --- a/lnbits/commands.py +++ b/lnbits/commands.py @@ -19,8 +19,6 @@ from .helpers import ( url_for_vendored, ) -path = settings.lnbits_path - @click.command("migrate") def db_migrate(): @@ -38,15 +36,17 @@ def transpile_scss(): warnings.simplefilter("ignore") from scss.compiler import compile_string # type: ignore - with open(os.path.join(path, "static/scss/base.scss")) as scss: - with open(os.path.join(path, "static/css/base.css"), "w") as css: + with open(os.path.join(settings.lnbits_path, "static/scss/base.scss")) as scss: + with open( + os.path.join(settings.lnbits_path, "static/css/base.css"), "w" + ) as css: css.write(compile_string(scss.read())) def bundle_vendored(): for getfiles, outputpath in [ - (get_js_vendored, os.path.join(path, "static/bundle.js")), - (get_css_vendored, os.path.join(path, "static/bundle.css")), + (get_js_vendored, os.path.join(settings.lnbits_path, "static/bundle.js")), + (get_css_vendored, os.path.join(settings.lnbits_path, "static/bundle.css")), ]: output = "" for path in getfiles():