0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 03:31:50 +02:00

fix(ringprogressbar): removed hard-coded endpoint strings

This commit is contained in:
2024-06-24 16:45:42 +02:00
committed by wyzula_j
parent 4a9d0c9e44
commit 1de3cbf65a

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Literal, Optional
from bec_lib.endpoints import EndpointInfo
from bec_lib.endpoints import EndpointInfo, MessageEndpoints
from pydantic import BaseModel, Field, field_validator
from pydantic_core import PydanticCustomError
from qtpy import QtGui
@ -21,14 +21,14 @@ class ProgressbarConnections(BaseModel):
slot = values.data["slot"]
v = v.endpoint if isinstance(v, EndpointInfo) else v
if slot == "on_scan_progress":
if v != "scans/scan_progress":
if v != MessageEndpoints.scan_progress().endpoint:
raise PydanticCustomError(
"unsupported endpoint",
"For slot 'on_scan_progress', endpoint must be MessageEndpoint.scan_progress or 'scans/scan_progress'.",
{"wrong_value": v},
)
elif slot == "on_device_readback":
if not v.startswith("internal/devices/readback/"):
if not v.startswith(MessageEndpoints.device_readback("").endpoint):
raise PydanticCustomError(
"unsupported endpoint",
"For slot 'on_device_readback', endpoint must be MessageEndpoint.device_readback(device) or 'internal/devices/readback/{device}'.",