web/views/schema.py
changeset 10970 894c14f08380
parent 10405 7b27a7443180
child 10981 45bc791275b4
--- a/web/views/schema.py	Wed Dec 09 16:36:17 2015 +0100
+++ b/web/views/schema.py	Mon Dec 14 12:11:44 2015 +0100
@@ -657,10 +657,13 @@
                                               }))
         # svg image file
         fd, tmpfile = tempfile.mkstemp('.svg')
-        os.close(fd)
-        generator.generate(visitor, prophdlr, tmpfile)
-        with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile:
-            self.w(svgfile.read())
+        try:
+            os.close(fd)
+            generator.generate(visitor, prophdlr, tmpfile)
+            with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile:
+                self.w(svgfile.read())
+        finally:
+            os.unlink(tmpfile)
 
 # breadcrumbs ##################################################################