[Buildbot-commits] buildbot/buildbot/status builder.py,1.42,1.43

Brian Warner warner at users.sourceforge.net
Fri Nov 12 22:36:41 UTC 2004


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29087/buildbot/status

Modified Files:
	builder.py 
Log Message:
(BuilderStatus.saveYourself): use a safer w32-compatible approach, and only
use it on windows
(BuildStatus.saveYourself): same


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- builder.py	11 Nov 2004 20:47:15 -0000	1.42
+++ builder.py	12 Nov 2004 22:36:38 -0000	1.43
@@ -5,7 +5,7 @@
 from twisted.python import log, components
 from twisted.internet import reactor, defer
 
-import time, os.path, shutil
+import time, os.path, shutil, sys
 try:
     import cPickle as pickle
 except ImportError:
@@ -781,13 +781,14 @@
         tmpfilename = filename + ".tmp"
         try:
             pickle.dump(self, open(tmpfilename, "w"), -1)
-            try:
-                os.rename(tmpfilename, filename)
-            except OSError:
-                # windows cannot rename a file on top of an existing one
+            if sys.platform == 'win32':
+                # windows cannot rename a file on top of an existing one, so
+                # fall back to delete-first. There are ways this can fail and
+                # lose the builder's history, so we avoid using it in the
+                # general (non-windows) case
                 os.unlink(filename)
-                os.rename(tmpfilename, filename)
-        except Exception, e:
+            os.rename(tmpfilename, filename)
+        except:
             log.msg("unable to save build %s-#%d" % (self.builder.name,
                                                      self.number))
             log.err()
@@ -872,13 +873,11 @@
         tmpfilename = filename + ".tmp"
         try:
             pickle.dump(self, open(tmpfilename, "w"), -1)
-            try:
-                os.rename(tmpfilename, filename)
-            except OSError:
+            if sys.platform == 'win32':
                 # windows cannot rename a file on top of an existing one
                 os.unlink(filename)
-                os.rename(tmpfilename, filename)
-        except Exception, e:
+            os.rename(tmpfilename, filename)
+        except:
             log.msg("unable to save builder %s" % self.name)
             log.err()
         





More information about the Commits mailing list