0

Added the ability to specify multiple crop zones.

This commit is contained in:
matrixhacker
2014-05-09 23:44:46 -04:00
parent 8881ba608d
commit b6ac54a2b6
5 changed files with 63 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ import tempfile
import shutil
import logging
import stat
import errno
default_caps = {"chmod_works": True, "rename_works": True}
@@ -150,6 +151,20 @@ class FileReplacer(object):
else:
# copy permission bits, if needed
if self.caps.get("chmod_works") and os.path.exists(self.destname):
shutil.copymode(self.destname, self.tmpname)
try:
shutil.copymode(self.destname, self.tmpname)
except OSError, e:
# Ignore errno ENOENT: file does not exist. Due to a race
# condition, two processes could conceivably try and update
# the same temp file at the same time
if e.errno != errno.ENOENT:
raise
# atomic rename into place
os.rename(self.tmpname, self.destname)
try:
os.rename(self.tmpname, self.destname)
except OSError, e:
# Ignore errno ENOENT: file does not exist. Due to a race
# condition, two processes could conceivably try and update
# the same temp file at the same time
if e.errno != errno.ENOENT:
raise