Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webviz build cannot be used in environments where webbrowser.get fails #604

Open
oysteinequinor opened this issue Jul 12, 2022 · 0 comments

Comments

@oysteinequinor
Copy link

Describe the bug
webviz build fails to provide the login token if webbrowser.get fails.

How to reproduce
Run webviz build in WSL without installing a browser inside of WSL.

Expected behavior
I expect an alternative way of accessing the application, such as a link with the token. I can then click or copy/paste the link from the terminal manually.

Suggested workaround/fix

diff --git a/webviz_config/utils/_localhost_open_browser.py b/webviz_config/utils/_localhost_open_browser.py
index 153641d..8d2e85d 100644
--- a/webviz_config/utils/_localhost_open_browser.py
+++ b/webviz_config/utils/_localhost_open_browser.py
@@ -17,8 +17,17 @@ class LocalhostOpenBrowser:
         self._port = port
         self._token = token

+        # Only open new browser tab if not a reload process
         if not is_reload_process():
-            # Only open new browser tab if not a reload process
+
+            # Print url if browser detection fails (might happen in headless installs)
+            try:
+                webbrowser.get()
+            except webbrowser.Error:
+                print("Automatic browser detection failed. Open link manually.")
+                print(self._url(with_token=True))
+                return
+
             threading.Thread(target=self._timer).start()

     def _timer(self) -> None:

Additional context
I am using this workaround to make webviz work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant