Skip to content

Commit 82976ac

Browse files
committed
Use rest client for getting stomp config
1 parent cc59d35 commit 82976ac

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

src/blueapi/cli/cli.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from blueapi.client import BlueapiClient
2525
from blueapi.client.event_bus import AnyEvent, BlueskyStreamingError, EventBusClient
2626
from blueapi.client.rest import (
27+
BlueapiRestClient,
2728
BlueskyRemoteControlError,
2829
InvalidParametersError,
2930
UnauthorisedAccessError,
@@ -32,6 +33,7 @@
3233
from blueapi.config import (
3334
ApplicationConfig,
3435
ConfigLoader,
36+
RestConfig,
3537
)
3638
from blueapi.core import OTLP_EXPORT_ENABLED, DataEvent
3739
from blueapi.log import set_up_logging
@@ -68,17 +70,6 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
6870
return wrapper
6971

7072

71-
def _default_config(ctx: click.Context) -> None:
72-
ctx.ensure_object(dict)
73-
config_loader = ConfigLoader(ApplicationConfig)
74-
75-
loaded_config: ApplicationConfig = config_loader.load()
76-
77-
set_up_logging(loaded_config.logging)
78-
79-
ctx.obj["config"] = loaded_config
80-
81-
8273
def _load_config(
8374
ctx: click.Context,
8475
config: Path | None | tuple[Path, ...],
@@ -314,7 +305,6 @@ def controller(
314305

315306
ctx.ensure_object(dict)
316307
ctx.obj["fmt"] = OutputFormat(output)
317-
318308
config: ApplicationConfig = ctx.obj["config"]
319309

320310
if url is not None:
@@ -324,11 +314,18 @@ def controller(
324314
"over a provided url"
325315
)
326316
else:
327-
config.api.url = HttpUrl(url)
328-
329-
tmp_client = BlueapiClient.from_config(config)
330-
config.stomp = tmp_client.get_stomp_config()
331-
ctx.obj["config"] = config
317+
tmp_client = BlueapiRestClient(RestConfig(url=HttpUrl(url)))
318+
stomp_config = None
319+
try:
320+
stomp_config = tmp_client.get_stomp_config()
321+
config.stomp = stomp_config
322+
config.api.url = url
323+
ctx.obj["config"] = config
324+
except Exception:
325+
LOGGER.error(
326+
"Server does not support --url access for "
327+
"this command. Please use a config file.",
328+
)
332329

333330
set_up_logging(config.logging)
334331
ctx.obj["client"] = BlueapiClient.from_config(config)

src/blueapi/client/client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ def from_config(cls, config: ApplicationConfig) -> "BlueapiClient":
7171
else:
7272
return cls(rest)
7373

74-
def get_stomp_config(self):
75-
return self._rest.get_stomp_config()
76-
7774
@start_as_current_span(TRACER)
7875
def get_plans(self) -> PlanResponse:
7976
"""

0 commit comments

Comments
 (0)