fix(webpage): name the setup's own client in the web password hint
The "no web authentication yet" hint always said flomni.set_web_password(), which doesn't exist in a LamNI session. Each generator now declares CLIENT_NAME and the hint uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALDnH16dC6iyHjhe5Ey4w9
This commit was merged in pull request #328.
This commit is contained in:
1 parent
636eb55e96
commit
ca96f41a45
4 files changed
+46
-2
No files matched your search
@@ -46,6 +46,8 @@ class LamniWebpageGenerator(WebpageGeneratorBase):
|
||||
sample name, and measurement settings.
|
||||
"""
|
||||
|
||||
CLIENT_NAME = "lamni"
|
||||
|
||||
# LamNI's tomo-queue jobs (added via TomoQueueMixin, see
|
||||
# OMNY_shared/tomo_queue_mixin.py) are persisted under the same
|
||||
# "tomo_queue" global var key flomni uses, so the shared "Tomo queue"
|
||||
|
||||
@@ -443,6 +443,10 @@ class WebpageGeneratorBase:
|
||||
whole shared output dir, EPS files included.
|
||||
"""
|
||||
|
||||
# Name of the setup's object in the BEC client namespace (e.g. "lamni"),
|
||||
# used in console hints such as the set_web_password() one.
|
||||
CLIENT_NAME: str | None = None
|
||||
|
||||
HAS_TOMO_QUEUE = True
|
||||
HAS_EPS_STATUS = True
|
||||
TOMO_TYPES = {
|
||||
@@ -816,7 +820,8 @@ class WebpageGeneratorBase:
|
||||
_BOLD_RED = "\033[1;31m"
|
||||
_RESET = "\033[0m"
|
||||
print(f"{_BOLD_RED}***\nWebpageGenerator: '{current_account}' has no web authentication yet.{_RESET}")
|
||||
print(f"{_BOLD_RED} To set a password run: flomni.set_web_password(\"your_password\")\n***{_RESET}")
|
||||
prefix = f"{self.CLIENT_NAME}." if self.CLIENT_NAME else ""
|
||||
print(f"{_BOLD_RED} To set a password run: {prefix}set_web_password(\"your_password\")\n***{_RESET}")
|
||||
|
||||
def _clear_session_htpasswd(self) -> None:
|
||||
"""Write an empty session.htpasswd locally and upload it."""
|
||||
@@ -835,7 +840,7 @@ class WebpageGeneratorBase:
|
||||
The username is taken from bec.active_account (e.g. 'p23092').
|
||||
|
||||
Example::
|
||||
flomni.webpage_gen.set_web_password("my_secret_password")
|
||||
flomni.set_web_password("my_secret_password")
|
||||
"""
|
||||
if self._set_password_url is None:
|
||||
print("set_web_password: no upload URL configured — cannot reach server")
|
||||
|
||||
@@ -54,6 +54,8 @@ class FlomniWebpageGenerator(WebpageGeneratorBase):
|
||||
Logo: flOMNI.png from the same directory as this file.
|
||||
"""
|
||||
|
||||
CLIENT_NAME = "flomni"
|
||||
|
||||
# Global-var names of the tomo parameters to read live for the
|
||||
# 'Current measurement' section. Kept in the same order as, and matching,
|
||||
# the tomo queue's TQ_PARAM_DISPLAY keys so the two render identically.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""The 'no web authentication' hint names the setup's own client object."""
|
||||
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
from csaxs_bec.bec_ipython_client.plugins.flomni.flomni_webpage_generator import (
|
||||
FlomniWebpageGenerator,
|
||||
)
|
||||
from csaxs_bec.bec_ipython_client.plugins.LamNI.LamNI_webpage_generator import (
|
||||
LamniWebpageGenerator,
|
||||
)
|
||||
from csaxs_bec.bec_ipython_client.plugins.OMNY_shared.webpage_generator_base import (
|
||||
WebpageGeneratorBase,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"cls, expected",
|
||||
[
|
||||
(LamniWebpageGenerator, 'lamni.set_web_password("your_password")'),
|
||||
(FlomniWebpageGenerator, 'flomni.set_web_password("your_password")'),
|
||||
(WebpageGeneratorBase, 'run: set_web_password("your_password")'),
|
||||
],
|
||||
)
|
||||
def test_password_hint_uses_client_name(cls, expected, capsys):
|
||||
gen = object.__new__(cls)
|
||||
gen._session_query_url = "http://example.invalid/session.php"
|
||||
gen._bec = types.SimpleNamespace(active_account="p12345")
|
||||
gen._get_remote_session_user = lambda: None
|
||||
gen._check_session_user()
|
||||
out = capsys.readouterr().out
|
||||
assert expected in out
|
||||
if cls is not FlomniWebpageGenerator:
|
||||
assert "flomni." not in out
|
||||
Reference in new issue
Block a user