##// END OF EJS Templates
Check if latex/dvipng exist before calling them
Takafumi Arakaki -
Show More
@@ -24,6 +24,8 b' import tempfile'
24 24 import shutil
25 25 import subprocess
26 26
27 from IPython.utils.process import find_cmd, FindCmdError
28
27 29 #-----------------------------------------------------------------------------
28 30 # Tools
29 31 #-----------------------------------------------------------------------------
@@ -70,6 +72,11 b' def latex_to_png_mpl(s):'
70 72
71 73 def latex_to_png_dvipng(s):
72 74 try:
75 find_cmd('latex')
76 find_cmd('dvipng')
77 except FindCmdError:
78 return None
79 try:
73 80 workdir = tempfile.mkdtemp()
74 81 tmpfile = os.path.join(workdir, "tmp.tex")
75 82 dvifile = os.path.join(workdir, "tmp.dvi")
@@ -91,8 +98,6 b' def latex_to_png_dvipng(s):'
91 98
92 99 with open(outfile) as f:
93 100 bin_data = f.read()
94 except subprocess.CalledProcessError:
95 bin_data = None
96 101 finally:
97 102 shutil.rmtree(workdir)
98 103 return bin_data
General Comments 0
You need to be logged in to leave comments. Login now