@@ -255,16 +255,22 @@ def make_dvi(self, tex, fontsize):
255
255
% (os .path .split (texfile )[- 1 ], outfile ))
256
256
mpl .verbose .report (command , 'debug' )
257
257
exit_status = os .system (command )
258
- fh = file (outfile )
258
+ try :
259
+ fh = file (outfile )
260
+ report = fh .read ()
261
+ fh .close ()
262
+ except IOError :
263
+ report = 'No latex error report available.'
259
264
if exit_status :
260
265
raise RuntimeError (('LaTeX was not able to process the following \
261
- string:\n %s\n Here is the full report generated by LaTeX: \n \n '% repr (tex )) + fh .read ())
262
- else : mpl .verbose .report (fh .read (), 'debug' )
263
- fh .close ()
266
+ string:\n %s\n Here is the full report generated by LaTeX: \n \n '% repr (tex )) + report )
267
+ else : mpl .verbose .report (report , 'debug' )
264
268
for fname in glob .glob (basefile + '*' ):
265
269
if fname .endswith ('dvi' ): pass
266
270
elif fname .endswith ('tex' ): pass
267
- else : os .remove (fname )
271
+ else :
272
+ try : os .remove (fname )
273
+ except OSError : pass
268
274
269
275
return dvifile
270
276
@@ -282,14 +288,19 @@ def make_png(self, tex, fontsize, dpi):
282
288
os .path .split (dvifile )[- 1 ], outfile ))
283
289
mpl .verbose .report (command , 'debug' )
284
290
exit_status = os .system (command )
285
- fh = file (outfile )
291
+ try :
292
+ fh = file (outfile )
293
+ report = fh .read ()
294
+ fh .close ()
295
+ except IOError :
296
+ report = 'No dvipng error report available.'
286
297
if exit_status :
287
298
raise RuntimeError ('dvipng was not able to \
288
299
process the flowing file:\n %s\n Here is the full report generated by dvipng: \
289
- \n \n '% dvifile + fh . read () )
290
- else : mpl .verbose .report (fh . read () , 'debug' )
291
- fh . close ( )
292
- os . remove ( outfile )
300
+ \n \n '% dvifile + report )
301
+ else : mpl .verbose .report (report , 'debug' )
302
+ try : os . remove ( outfile )
303
+ except OSError : pass
293
304
294
305
return pngfile
295
306
@@ -363,7 +374,7 @@ def get_grey(self, tex, fontsize=None, dpi=None):
363
374
# white (1) this reduces to red = 1-alpha or alpha = 1-red
364
375
#alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here?
365
376
alpha = 1 - X [:,:,0 ]
366
-
377
+
367
378
else :
368
379
alpha = X [:,:,- 1 ]
369
380
0 commit comments