On Wednesday 16 July 2008 07:20:59 am Ian Harry wrote:
> [EMAIL PROTECTED] 07:14 AM matplotlib]$ diff texmanager.py
> /usr/lib64/python2.4/site-packages/matplotlib/texmanager.py
> 248c248
> <             fh = file(outfile,'a')
> ---
>
> >             fh = file(outfile)
>
> 252,254c252
> <             else:
> <               try: verbose.report(fh.read(), 'debug')
> <               except: pass
> ---
>
> >             else: verbose.report(fh.read(), 'debug')
>
> 259,261c257,258
> <                 else:
> <                   try: os.remove(fname)
> <                   except: pass
> ---
>
> >                 else: os.remove(fname)
>
> 280c277
> <             fh = file(outfile,'a')
> ---
>
> >             fh = file(outfile)
>
> 285,287c282
> <             else:
> <               try: verbose.report(fh.read(), 'debug')
> <               except: pass
> ---
>
> >             else: verbose.report(fh.read(), 'debug')
>
> 289,290c284
> <             try: os.remove(outfile)
> <             except: pass
> ---
>
> >             os.remove(outfile)
>
> 314c308
> <             # else: verbose.report(fh.read(), 'debug')
> ---
>
> >             else: verbose.report(fh.read(), 'debug')
>
> --snip--

I took a different approach:

Index: lib/matplotlib/texmanager.py
===================================================================
--- lib/matplotlib/texmanager.py        (revision 5771)
+++ lib/matplotlib/texmanager.py        (working copy)
@@ -273,16 +273,22 @@
                             %(os.path.split(texfile)[-1], outfile))
             mpl.verbose.report(command, 'debug')
             exit_status = os.system(command)
-            fh = file(outfile)
+            try:
+                fh = file(outfile)
+                report = fh.read()
+                fh.close()
+            except IOError:
+                report = 'No latex error report available.'
             if exit_status:
                 raise RuntimeError(('LaTeX was not able to process the 
following \
-string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + 
fh.read())
-            else: mpl.verbose.report(fh.read(), 'debug')
-            fh.close()
+string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + 
report)
+            else: mpl.verbose.report(report, 'debug')
             for fname in glob.glob(basefile+'*'):
                 if fname.endswith('dvi'): pass
                 elif fname.endswith('tex'): pass
-                else: os.remove(fname)
+                else:
+                    try: os.remove(fname)
+                    except OSError: pass

         return dvifile

@@ -305,14 +311,19 @@
                         os.path.split(dvifile)[-1], outfile))
             mpl.verbose.report(command, 'debug')
             exit_status = os.system(command)
-            fh = file(outfile)
+            try:
+                fh = file(outfile)
+                report = fh.read()
+                fh.close()
+            except IOError:
+                report = 'No dvipng error report available.'
             if exit_status:
                 raise RuntimeError('dvipng was not able to \
 process the flowing file:\n%s\nHere is the full report generated by dvipng: \
-\n\n'% dvifile + fh.read())
-            else: mpl.verbose.report(fh.read(), 'debug')
-            fh.close()
-            os.remove(outfile)
+\n\n'% dvifile + report)
+            else: mpl.verbose.report(report, 'debug')
+            try: os.remove(outfile)
+            except OSError: pass

         return pngfile


Would you update from svn and see if it works for you?

Thanks,
Darren

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to