Added the ability to specify multiple crop zones.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -225,15 +225,23 @@ def validateOutputDir(d):
|
||||
return expand_path(d)
|
||||
|
||||
def validateCrop(value):
|
||||
if len(value) != 4:
|
||||
raise ValidationException("The value for the 'crop' setting must be a tuple of length 4")
|
||||
a, b, c, d = tuple(int(x) for x in value)
|
||||
|
||||
if a >= c:
|
||||
a, c = c, a
|
||||
if b >= d:
|
||||
b, d = d, b
|
||||
return (a, b, c, d)
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
|
||||
cropZones = []
|
||||
for zone in value:
|
||||
if len(zone) != 4:
|
||||
raise ValidationException("The value for the 'crop' setting must be an array of tuples of length 4")
|
||||
a, b, c, d = tuple(int(x) for x in zone)
|
||||
|
||||
if a >= c:
|
||||
a, c = c, a
|
||||
if b >= d:
|
||||
b, d = d, b
|
||||
|
||||
cropZones.append((a, b, c, d))
|
||||
|
||||
return cropZones
|
||||
|
||||
def validateObserver(observer):
|
||||
if all(map(lambda m: hasattr(observer, m), ['start', 'add', 'update', 'finish'])):
|
||||
|
||||
@@ -947,7 +947,14 @@ class TileSet(object):
|
||||
if self.options['optimizeimg']:
|
||||
optimize_image(tmppath, imgformat, self.options['optimizeimg'])
|
||||
|
||||
os.utime(tmppath, (max_mtime, max_mtime))
|
||||
try:
|
||||
os.utime(tmppath, (max_mtime, max_mtime))
|
||||
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
|
||||
|
||||
def _render_rendertile(self, tile):
|
||||
"""Renders the given render-tile.
|
||||
|
||||
Reference in New Issue
Block a user