web/views/schema.py
changeset 10981 45bc791275b4
parent 10740 59e89db3a67d
parent 10970 894c14f08380
--- a/web/views/schema.py	Fri Dec 11 14:07:51 2015 +0100
+++ b/web/views/schema.py	Tue Dec 15 14:12:59 2015 +0100
@@ -660,10 +660,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 ##################################################################