Skip to content

Commit 33d92e8

Browse files
committed
auth banner
1 parent 7b560f3 commit 33d92e8

File tree

2 files changed

+47
-18
lines changed

2 files changed

+47
-18
lines changed

services/web/server/src/simcore_service_webserver/_meta.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
api_version_prefix: str = API_VTAG
2424

2525

26-
# kids drawings :-)
27-
2826
WELCOME_MSG = r"""
2927
_ _ _
3028
| | | | | |
@@ -45,6 +43,7 @@
4543
(_)) __((/ __|
4644
| (_ || (__
4745
\___| \___|
46+
4847
"""
4948

5049
WELCOME_DB_LISTENER_MSG = r"""
@@ -54,5 +53,17 @@
5453
| | | _ <___| |--| |___ \- -| __| | | __| _ <
5554
|_____\_____/ \_____\___<_____/|__|\_____\__|__\_____\__|\_/
5655
57-
5856
"""
57+
58+
# SEE https://patorjk.com/software/taag/#p=display&f=BlurVision%20ASCII&t=Auth%0A
59+
WELCOME_AUTH_APP_MSG = r"""
60+
░▒▓██████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░
61+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
62+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
63+
░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░
64+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
65+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
66+
░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ {}
67+
""".format(
68+
f"v{__version__}"
69+
)

services/web/server/src/simcore_service_webserver/application.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Main application"""
33

44
import logging
5+
from collections.abc import Callable
56
from pprint import pformat
67
from typing import Any
78

@@ -11,7 +12,13 @@
1112
setup_realtime_collaboration,
1213
)
1314

14-
from ._meta import WELCOME_DB_LISTENER_MSG, WELCOME_GC_MSG, WELCOME_MSG, info
15+
from ._meta import (
16+
WELCOME_AUTH_APP_MSG,
17+
WELCOME_DB_LISTENER_MSG,
18+
WELCOME_GC_MSG,
19+
WELCOME_MSG,
20+
info,
21+
)
1522
from .activity.plugin import setup_activity
1623
from .announcements.plugin import setup_announcements
1724
from .api_keys.plugin import setup_api_keys
@@ -62,18 +69,29 @@
6269
_logger = logging.getLogger(__name__)
6370

6471

65-
async def _welcome_banner(app: web.Application):
66-
settings = get_application_settings(app)
67-
print(WELCOME_MSG, flush=True) # noqa: T201
68-
if settings.WEBSERVER_GARBAGE_COLLECTOR:
69-
print("with", WELCOME_GC_MSG, flush=True) # noqa: T201
70-
if settings.WEBSERVER_DB_LISTENER:
71-
print("with", WELCOME_DB_LISTENER_MSG, flush=True) # noqa: T201
72+
def _create_welcome_banner(banner_msg: str) -> Callable:
73+
"""Creates a welcome banner function with optional GC and DB listener messages"""
74+
75+
async def _welcome_banner(app: web.Application):
76+
settings = get_application_settings(app)
77+
78+
print(banner_msg, flush=True) # noqa: T201
79+
if settings.WEBSERVER_GARBAGE_COLLECTOR:
80+
print("with", WELCOME_GC_MSG, flush=True) # noqa: T201
81+
if settings.WEBSERVER_DB_LISTENER:
82+
print("with", WELCOME_DB_LISTENER_MSG, flush=True) # noqa: T201
83+
84+
return _welcome_banner
85+
86+
87+
def _create_finished_banner() -> Callable:
88+
"""Creates a finished banner function"""
7289

90+
async def _finished_banner(app: web.Application):
91+
assert app # nosec
92+
print(info.get_finished_banner(), flush=True) # noqa: T201
7393

74-
async def _finished_banner(app: web.Application):
75-
assert app # nosec
76-
print(info.get_finished_banner(), flush=True) # noqa: T201
94+
return _finished_banner
7795

7896

7997
def create_application() -> web.Application:
@@ -166,8 +184,8 @@ def create_application() -> web.Application:
166184
setup_realtime_collaboration(app)
167185

168186
# NOTE: *last* events
169-
app.on_startup.append(_welcome_banner)
170-
app.on_shutdown.append(_finished_banner)
187+
app.on_startup.append(_create_welcome_banner(WELCOME_MSG))
188+
app.on_shutdown.append(_create_finished_banner())
171189

172190
_logger.debug("Routes in app: \n %s", pformat(app.router.named_resources()))
173191

@@ -183,8 +201,8 @@ def create_application_auth() -> web.Application:
183201
setup_login_auth(app)
184202

185203
# NOTE: *last* events
186-
app.on_startup.append(_welcome_banner)
187-
app.on_shutdown.append(_finished_banner)
204+
app.on_startup.append(_create_welcome_banner(WELCOME_AUTH_APP_MSG))
205+
app.on_shutdown.append(_create_finished_banner())
188206

189207
_logger.debug(
190208
"Routes in application-auth: \n %s", pformat(app.router.named_resources())

0 commit comments

Comments
 (0)