Skip to content

Commit a868c97

Browse files
committed
Show messages describing why the TUI cannot connect to the server
1 parent 9f64b06 commit a868c97

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/murfey/client/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,20 @@ def run():
275275
rich_handler.setLevel(logging.DEBUG if args.debug else logging.INFO)
276276

277277
# Set up websocket app and handler
278-
client_id = requests.get(
278+
client_id_response = requests.get(
279279
f"{murfey_url.geturl()}{url_path_for('session_control.router', 'new_client_id')}"
280-
).json()
280+
)
281+
if client_id_response.status_code == 401:
282+
exit(
283+
"This instrument is not authorised to run the TUI app; please use the "
284+
"Murfey web UI instead"
285+
)
286+
elif client_id_response.status_code != 200:
287+
exit(
288+
"Unable to establish connection to Murfey server: \n"
289+
f"{client_id_response.json()}"
290+
)
291+
client_id: dict = client_id_response.json()
281292
ws = murfey.client.websocket.WSApp(
282293
server=args.server,
283294
id=client_id["new_id"],

0 commit comments

Comments
 (0)