Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
graph.render(filename, view=False)
else:
try:
from IPython import get_ipython
assert get_ipython().config.get("IPKernelApp") is not None
except Exception:
with tempfile.NamedTemporaryFile(delete=False) as tmp:
tmp.close()
try:
graph.render(tmp.name, view=True)
except graphviz.backend.ExecutableNotFound:
msg = "It appears you do not have Graphviz installed, or it is not on your PATH.\n"
msg += "Please install Graphviz from http://www.graphviz.org/download/\n"
msg += "And note: just installing the `graphviz` python package is not sufficient!"
raise graphviz.backend.ExecutableNotFound(msg)
finally:
os.unlink(tmp.name)
return graph
def engine(self, engine):
engine = engine.lower()
if engine not in backend.ENGINES:
raise ValueError('unknown engine: %r' % engine)
self._engine = engine