Skip to content

Commit 2cdc55b

Browse files
Enrico Usaidemartinofra
authored andcommitted
Show url message when webbrowser.open_new returns False
Signed-off-by: Enrico Usai <[email protected]>
1 parent c9505bf commit 2cdc55b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

cli/pcluster/dcv/connect.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,14 @@ def dcv_connect(args):
8787
url = "https://{IP}:{PORT}?authToken={TOKEN}#{SESSION_ID}".format(
8888
IP=master_ip, PORT=dcv_server_port, TOKEN=dcv_session_token, SESSION_ID=dcv_session_id
8989
)
90+
url_message = "Please use the following one-time URL in your browser within 30 seconds:\n{0}".format(url)
9091

9192
if args.show_url:
92-
LOGGER.info("Please use the following one-time URL in your browser within 30 seconds:\n{0}".format(url))
93+
LOGGER.info(url_message)
9394
return
9495

9596
try:
96-
webbrowser.open_new(url)
97-
except webbrowser.Error:
98-
LOGGER.info(
99-
"Unable to open the Web browser. "
100-
"Please use the following URL in your browser within 30 seconds:\n{0}".format(url)
101-
)
97+
if not webbrowser.open_new(url):
98+
raise webbrowser.Error("Unable to open the Web browser.")
99+
except webbrowser.Error as e:
100+
LOGGER.info("{0}\n{1}".format(e, url_message))

0 commit comments

Comments
 (0)