[mirrorbrain-commits] r7922 - /trunk/mirrordoctor/mb/mirrorlists.py

From: <poeml_at_mirrorbrain.org>
Date: Sun, 06 Dec 2009 21:46:52 -0000
Author: poeml
Date: Sun Dec  6 22:46:51 2009
New Revision: 7922

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7922&view=rev
Log:
mb mirrorlist:
- try harder to not leave temp files -- even when crashing.
- in the footer, add a link to our project.

Modified:
    trunk/mirrordoctor/mb/mirrorlists.py

Modified: trunk/mirrordoctor/mb/mirrorlists.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrordoctor/mb/mirrorlists.py?rev=7922&r1=7921&r2=7922&view=diff
==============================================================================
--- trunk/mirrordoctor/mb/mirrorlists.py (original)
+++ trunk/mirrordoctor/mb/mirrorlists.py Sun Dec  6 22:46:51 2009
@@ -33,19 +33,22 @@
         # without the risk that the webserver sends out incomplete content.
         (fd, tmpfname) = tempfile.mkstemp(prefix = '.' + os.path.basename(fname),
                                           dir = os.path.dirname(fname))
-        os.chmod(tmpfname, 0644)
-        f = os.fdopen(fd, 'w')
-
-        for i in gen:
-            f.write(i + '\n')
-
-        f.close()
         try:
-            os.rename(tmpfname, fname)
-        except:
-            print >>sys.stderr, 'could not rename file'
-            os.unlink(tmpfname)
-            raise
+            os.chmod(tmpfname, 0644)
+            f = os.fdopen(fd, 'w')
+
+            for i in gen:
+                f.write(i + '\n')
+
+            f.close()
+            try:
+                os.rename(tmpfname, fname)
+            except:
+                print >>sys.stderr, 'could not rename file'
+                raise
+        finally:
+            if os.path.exists(tmpfname):
+                os.unlink(tmpfname)
 
 
 
@@ -102,9 +105,9 @@
 
     html_footer = """\
 
-  <p>
-  Generated by MirrorBrain on %(utc)s.
-  </p>
+  <address>
+  Generated %(utc)s by MirrorBrain
+  </address>
   </body>
 </html>
 """




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Sun Dec 06 2009 - 21:46:54 GMT

This archive was generated by hypermail 2.2.0 : Sun Dec 06 2009 - 22:45:07 GMT