2424from blueapi .client import BlueapiClient
2525from blueapi .client .event_bus import AnyEvent , BlueskyStreamingError , EventBusClient
2626from blueapi .client .rest import (
27+ BlueapiRestClient ,
2728 BlueskyRemoteControlError ,
2829 InvalidParametersError ,
2930 UnauthorisedAccessError ,
3233from blueapi .config import (
3334 ApplicationConfig ,
3435 ConfigLoader ,
36+ RestConfig ,
3537)
3638from blueapi .core import OTLP_EXPORT_ENABLED , DataEvent
3739from 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-
8273def _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 )
0 commit comments