Skip to content

Commit

Permalink
Fix LocalServer on MacOS py3.10 and earlier (#1003)
Browse files Browse the repository at this point in the history
* Fix LocalServer on MacOS py3.10 and earlier

* Remove reference to MacOSXOSAScript

* Update changelog.d/20240712_133910_derek_fix_local_server_login_on_mac.rst

Co-authored-by: Kurt McKee <[email protected]>

---------

Co-authored-by: Kurt McKee <[email protected]>
  • Loading branch information
derek-globus and kurtmckee authored Jul 12, 2024
1 parent faa3efe commit ccb264b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Fixed
~~~~~

- Fixed a GlobusApp bug which would cause LocalServerLoginFlowManager to error on
MacOS when versions earlier than Python 3.11. (:pr:`NUMBER`)
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ def _open_webbrowser(url: str) -> None:
"""
try:
browser = webbrowser.get()
if browser.name in BROWSER_BLACKLIST:
if hasattr(browser, "name"):
browser_name = browser.name
elif hasattr(browser, "_name"):
# MacOSXOSAScript only supports a public name attribute in py311 and later.
# https://github.com/python/cpython/issues/82828
browser_name = browser._name
else:
raise LocalServerLoginFlowError("Unable to determine local browser name.")

if browser_name in BROWSER_BLACKLIST:
raise LocalServerLoginFlowError(
"Cannot use LocalServerLoginFlowManager with "
f"text-only browser '{browser.name}'"
f"text-only browser '{browser_name}'"
)

if not browser.open(url, new=1):
raise LocalServerLoginFlowError("Failed to open browser '{browser.name}'")
raise LocalServerLoginFlowError(f"Failed to open browser '{browser_name}'")
except webbrowser.Error as exc:
raise LocalServerLoginFlowError("Failed to open browser") from exc

Expand Down

0 comments on commit ccb264b

Please sign in to comment.