Skip to content

Commit a547e37

Browse files
improve browser error messages
1 parent 2c2dd6a commit a547e37

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010

1111
### Fixed
1212
- Fixed regression introduced in version 5.0.0 where pandas/numpy arrays with `dtype` of Object were being converted to `list` values when added to a Figure ([#3292](https://github.com/plotly/plotly.py/issues/3292), [#3293](https://github.com/plotly/plotly.py/pull/3293))
13+
- Better detection of Chrome and Chromium browsers in the Renderers framework, especially on Linux ([#3278](https://github.com/plotly/plotly.py/pull/3278)) with thanks to [@c-chaitanya](https://github.com/c-chaitanya) for the contribution
1314

1415
## [5.1.0] - 2021-06-28
1516

packages/python/plotly/plotly/io/_base_renderers.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,21 @@ def open_html_in_browser(html, using=None, new=0, autoraise=True):
669669
if isinstance(html, six.string_types):
670670
html = html.encode("utf8")
671671

672-
if isinstance(using, tuple):
673-
try:
674-
using = [i for i in webbrowser._browsers.keys() if i in using][0]
675-
except IndexError:
676-
raise ValueError(
677-
"""
678-
Unable to find the given browser.
679-
Try one among the following 'chrome', 'chromium', 'firefox' or 'default' """
680-
)
672+
browser = None
673+
674+
if using is None:
675+
browser = webbrowser.get()
676+
else:
677+
if not isinstance(using, tuple):
678+
using = (using,)
679+
for browser_key in using:
680+
try:
681+
browser = webbrowser.get(browser_key)
682+
except webbrowser.Error:
683+
pass
684+
685+
if browser is None:
686+
raise ValueError("Can't locate a browser with key in " + str(using))
681687

682688
class OneShotRequestHandler(BaseHTTPRequestHandler):
683689
def do_GET(self):
@@ -694,7 +700,7 @@ def log_message(self, format, *args):
694700
pass
695701

696702
server = HTTPServer(("127.0.0.1", 0), OneShotRequestHandler)
697-
webbrowser.get(using).open(
703+
browser.open(
698704
"http://127.0.0.1:%s" % server.server_port, new=new, autoraise=autoraise
699705
)
700706

0 commit comments

Comments
 (0)