Revision: 5771
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5771&view=rev
Author:   dsdale
Date:     2008-07-17 12:01:50 +0000 (Thu, 17 Jul 2008)

Log Message:
-----------
improve error reporting in texmanager

Modified Paths:
--------------
    branches/v0_91_maint/CHANGELOG
    branches/v0_91_maint/lib/matplotlib/texmanager.py

Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG      2008-07-14 16:42:52 UTC (rev 5770)
+++ branches/v0_91_maint/CHANGELOG      2008-07-17 12:01:50 UTC (rev 5771)
@@ -1,3 +1,6 @@
+2008-07-16 Improve error handling in texmanager, thanks to Ian Henry 
+           for reporting - DSD
+
 2008-07-09 Improve mathtext radical rendering - MGD
 
 2008-07-08 Improve mathtext superscript placement - MGD

Modified: branches/v0_91_maint/lib/matplotlib/texmanager.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/texmanager.py   2008-07-14 16:42:52 UTC 
(rev 5770)
+++ branches/v0_91_maint/lib/matplotlib/texmanager.py   2008-07-17 12:01:50 UTC 
(rev 5771)
@@ -255,16 +255,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
 
@@ -282,14 +288,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
 
@@ -363,7 +374,7 @@
                 # white (1) this reduces to red = 1-alpha or alpha = 1-red
                 #alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here?
                 alpha = 1-X[:,:,0]
-                
+
             else:
                 alpha = X[:,:,-1]
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
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-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to