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
@@ -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 )
0 commit comments