From 937a867b95c5ac3544148d4728dbcee068ef905e Mon Sep 17 00:00:00 2001 From: mwfarb Date: Fri, 9 Aug 2024 11:11:56 -0400 Subject: [PATCH] fix(auth): remove automatic browser open for 4xx status --- arena/auth.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arena/auth.py b/arena/auth.py index 029fa5a..afaf71e 100644 --- a/arena/auth.py +++ b/arena/auth.py @@ -308,16 +308,12 @@ def urlopen(self, url, data=None, creds=False, csrf=None): return res.read().decode("utf-8") except (requests.exceptions.ConnectionError, ConnectionError, URLError, HTTPError) as err: print(f"{err}: {url}") - if isinstance(err, HTTPError) and round(err.code, -2) == 400: + if isinstance(err, HTTPError) and err.code in (401, 403): # user not authorized on website yet, they don"t have an ARENA username us = urlsplit(url) base_url = f"{us.scheme}://{us.netloc}" - print("Login with this account on the website first:") - print(f"Trying to open login page: {base_url}/user") - try: - webbrowser.open_new_tab(f"{base_url}/user") - except (webbrowser.Error) as error: - print(f"Console-only login. {error}") + print(f"Do you have a valid ARENA account on {base_url}?") + print(f"You can create an account in a web browser at: {base_url}/user") sys.exit("Terminating...")