Skip to content

Commit

Permalink
Fix for #1809 Python 2.7 incompatibility in the iframe renderer (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
carthurs authored and jonmmease committed Oct 15, 2019
1 parent 5084b35 commit d7021e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/python/plotly/codegen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from io import StringIO
from typing import List
import re
import errno


# Source code utilities
Expand All @@ -30,7 +31,11 @@ def write_source_py(py_source, filepath, leading_newlines=0):
# Make dir if needed
# ------------------
filedir = opath.dirname(filepath)
os.makedirs(filedir, exist_ok=True)
try:
os.makedirs(filedir)
except OSError as error:
if error.errno != errno.EEXIST:
raise

# Write file
# ----------
Expand Down
7 changes: 6 additions & 1 deletion packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import webbrowser
import inspect
import os
import errno

import six
from plotly.io import to_json, to_image, write_image, write_html
Expand Down Expand Up @@ -564,7 +565,11 @@ def to_mimebundle(self, fig_dict):
filename = self.build_filename()

# Make directory for
os.makedirs(self.html_directory, exist_ok=True)
try:
os.makedirs(self.html_directory)
except OSError as error:
if error.errno != errno.EEXIST:
raise

write_html(
fig_dict,
Expand Down

0 comments on commit d7021e8

Please sign in to comment.