Skip to content

Commit 2c1def0

Browse files
committed
Use rest client for getting stomp config
1 parent cc59d35 commit 2c1def0

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/blueapi/cli/cli.py

Lines changed: 14 additions & 6 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
@@ -314,7 +316,6 @@ def controller(
314316

315317
ctx.ensure_object(dict)
316318
ctx.obj["fmt"] = OutputFormat(output)
317-
318319
config: ApplicationConfig = ctx.obj["config"]
319320

320321
if url is not None:
@@ -324,11 +325,18 @@ def controller(
324325
"over a provided url"
325326
)
326327
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
328+
tmp_client = BlueapiRestClient(RestConfig(url=HttpUrl(url)))
329+
stomp_config = None
330+
try:
331+
stomp_config = tmp_client.get_stomp_config()
332+
config.stomp = stomp_config
333+
config.api.url = url
334+
ctx.obj["config"] = config
335+
except Exception:
336+
LOGGER.error(
337+
"Server does not support --url access for "
338+
"this command. Please use a config file.",
339+
)
332340

333341
set_up_logging(config.logging)
334342
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)