Remove a load more /names/

This commit is contained in:
Julian Stirling 2025-12-14 16:20:08 +00:00
parent e7f669cb56
commit 9ef417971f
15 changed files with 39 additions and 41 deletions

View file

@ -63,11 +63,11 @@ def customise_server(
def _get_scans_dir(config: dict) -> Optional[str]:
"""Read the config and return the scans directory.
Return is None if there is no /smart_scan/ thing loaded.
Return is None if there is no smart_scan thing loaded.
"""
if "/smart_scan/" in config["things"]:
if "smart_scan" in config["things"]:
try:
return config["things"]["/smart_scan/"]["kwargs"]["scans_folder"]
return config["things"]["smart_scan"]["kwargs"]["scans_folder"]
except KeyError as e:
msg = "Configuration error: smart scan should have scans_folder kwarg set"
raise RuntimeError(msg) from e
@ -96,7 +96,7 @@ def serve_from_cli(argv: Optional[list[str]] = None) -> None:
def shutdown_call() -> None:
try:
# Kill any mjpeg streams so that StreamingResponses close.
server.things["/camera/"].kill_mjpeg_streams()
server.things["camera"].kill_mjpeg_streams()
except BaseException as e:
# Catch anything and log as it is essential that this
# function cannot raise an unhandled exception or Uvicorn

View file

@ -731,7 +731,7 @@ class BaseCamera(lt.Thing):
return {}
CameraDependency = lt.deps.direct_thing_client_dependency(BaseCamera, "/camera/")
CameraDependency = lt.deps.direct_thing_client_dependency(BaseCamera, "camera")
RawCameraDependency = lt.deps.raw_thing_dependency(BaseCamera)

View file

@ -42,9 +42,9 @@ T = TypeVar("T")
P = ParamSpec("P")
CSMDep = lt.deps.direct_thing_client_dependency(
CameraStageMapper, "/camera_stage_mapping/"
CameraStageMapper, "camera_stage_mapping"
)
AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "/autofocus/")
AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "autofocus")
class ScanListInfo(BaseModel):

View file

@ -228,4 +228,4 @@ class BaseStage(lt.Thing):
self.move_absolute(cancel=cancel, x=xyz_pos[0], y=xyz_pos[1], z=xyz_pos[2])
StageDependency = lt.deps.direct_thing_client_dependency(BaseStage, "/stage/")
StageDependency = lt.deps.direct_thing_client_dependency(BaseStage, "stage")

View file

@ -30,9 +30,9 @@ from .camera_stage_mapping import CameraStageMapper
from .stage import StageDependency as StageDep
CSMDep = lt.deps.direct_thing_client_dependency(
CameraStageMapper, "/camera_stage_mapping/"
CameraStageMapper, "camera_stage_mapping"
)
AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "/autofocus/")
AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "autofocus")
## Size of movement in percentage of field of view
SMALL_STEP = 20

View file

@ -54,9 +54,8 @@ def action_button_for(action: Callable[..., Any], **kwargs: Any) -> ActionButton
:param kwargs: Any attribute of `ActionButton` except for ``thing`` or ``action``.
"""
thing = action.args[0]
thing_path = thing.path.strip("/")
action_name = action.func.__name__
return ActionButton(thing=thing_path, action=action_name, **kwargs)
return ActionButton(thing=thing.name, action=action_name, **kwargs)
class PropertyControl(BaseModel):
@ -94,7 +93,6 @@ def property_control_for(
:param kwargs: Any attribute of `PropertyControl` except for ``thing`` or
``property_name``. If label is not set here it will be the property name.
"""
thing_path = thing.path.strip("/")
if "label" not in kwargs:
kwargs["label"] = property_name
return PropertyControl(thing=thing_path, property_name=property_name, **kwargs)
return PropertyControl(thing=thing.name, property_name=property_name, **kwargs)