From 9a16dfa96092dbd185780cb7cf65d6584b660806 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 6 Oct 2020 12:59:06 -0300 Subject: [PATCH] remove annoying warnings and unnecessary prints. show a summary of some settings on startup when running __main__.py --- lnbits/__main__.py | 12 ++++++++++++ lnbits/app.py | 3 --- lnbits/commands.py | 13 ++++++++----- lnbits/tasks.py | 1 - 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lnbits/__main__.py b/lnbits/__main__.py index 6932fba2d..c86098ceb 100644 --- a/lnbits/__main__.py +++ b/lnbits/__main__.py @@ -1,9 +1,21 @@ from .app import create_app from .commands import migrate_databases, transpile_scss, bundle_vendored +from .settings import LNBITS_SITE_TITLE, SERVICE_FEE, DEBUG, LNBITS_DATA_FOLDER, WALLET migrate_databases() transpile_scss() bundle_vendored() app = create_app() + +print( + f"""Starting LNbits with + - site title: {LNBITS_SITE_TITLE} + - debug: {DEBUG} + - data folder: {LNBITS_DATA_FOLDER} + - funding source: {WALLET.__class__.__name__} + - service fee: {SERVICE_FEE} +""" +) + app.run(host=app.config["HOST"], port=app.config["PORT"]) diff --git a/lnbits/app.py b/lnbits/app.py index 112739d78..99099827c 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -1,4 +1,3 @@ -import trio # type: ignore import importlib from quart import g @@ -112,9 +111,7 @@ def register_async_tasks(app): @app.before_serving async def listeners(): run_deferred_async(app.nursery) - app.nursery.start_soon(invoice_listener) - print("started global invoice_listener.") @app.after_serving async def stop_listeners(): diff --git a/lnbits/commands.py b/lnbits/commands.py index 653175f32..a3dde9c24 100644 --- a/lnbits/commands.py +++ b/lnbits/commands.py @@ -1,11 +1,10 @@ +import warnings import click import importlib import re import os import sqlite3 -from scss.compiler import compile_string # type: ignore - from .core import migrations as core_migrations from .db import open_db, open_ext_db from .helpers import get_valid_extensions, get_css_vendored, get_js_vendored, url_for_vendored @@ -24,9 +23,13 @@ def handle_assets(): def transpile_scss(): - with open(os.path.join(LNBITS_PATH, "static/scss/base.scss")) as scss: - with open(os.path.join(LNBITS_PATH, "static/css/base.css"), "w") as css: - css.write(compile_string(scss.read())) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + from scss.compiler import compile_string # type: ignore + + with open(os.path.join(LNBITS_PATH, "static/scss/base.scss")) as scss: + with open(os.path.join(LNBITS_PATH, "static/css/base.css"), "w") as css: + css.write(compile_string(scss.read())) def bundle_vendored(): diff --git a/lnbits/tasks.py b/lnbits/tasks.py index 74b32e905..8a1a6a127 100644 --- a/lnbits/tasks.py +++ b/lnbits/tasks.py @@ -67,7 +67,6 @@ def register_invoice_listener(send_chan: trio.MemorySendChannel): A method intended for extensions to call when they want to be notified about new invoice payments incoming. """ - print(f"registering invoice_listener: {send_chan}") invoice_listeners.append(send_chan)