0

Add reporting of scanning/indexing regions. Shortened paths being sent to the worker processes, and removed os.path.join from _apply_render_worldtiles's inner loop.

This commit is contained in:
Xon
2011-03-21 08:03:18 +08:00
parent 059492b3a1
commit c1b7b12592
2 changed files with 25 additions and 14 deletions

View File

@@ -90,8 +90,8 @@ class QuadtreeGen(object):
# Make the destination dir # Make the destination dir
if not os.path.exists(destdir): if not os.path.exists(destdir):
os.mkdir(destdir) os.mkdir(destdir)
self.tiledir = tiledir self.tiledir = tiledir
if depth is None: if depth is None:
# Determine quadtree depth (midpoint is always 0,0) # Determine quadtree depth (midpoint is always 0,0)
for p in xrange(15): for p in xrange(15):
@@ -123,6 +123,9 @@ class QuadtreeGen(object):
self.world = worldobj self.world = worldobj
self.destdir = destdir self.destdir = destdir
self.full_tiledir = os.path.join(destdir, tiledir)
def print_statusline(self, complete, total, level, unconditional=False): def print_statusline(self, complete, total, level, unconditional=False):
if unconditional: if unconditional:
@@ -227,12 +230,13 @@ class QuadtreeGen(object):
colend = colstart + 2 colend = colstart + 2
rowend = rowstart + 4 rowend = rowstart + 4
# This image is rendered at: # This image is rendered at(relative to the worker's destdir):
dest = os.path.join(self.destdir, self.tiledir, *(str(x) for x in path)) tilepath = [str(x) for x in path]
tilepath = os.sep.join(tilepath)
#logging.debug("this is rendered at %s", dest) #logging.debug("this is rendered at %s", dest)
# Put this in the batch to be submited to the pool # Put this in the batch to be submited to the pool
batch.append((colstart, colend, rowstart, rowend, dest)) batch.append((colstart, colend, rowstart, rowend, tilepath))
tiles += 1 tiles += 1
if tiles >= batch_size: if tiles >= batch_size:
tiles = 0 tiles = 0
@@ -251,11 +255,14 @@ class QuadtreeGen(object):
batch = [] batch = []
tiles = 0 tiles = 0
for path in iterate_base4(zoom): for path in iterate_base4(zoom):
# This image is rendered at: # This image is rendered at(relative to the worker's destdir):
dest = os.path.join(self.destdir, self.tiledir, *(str(x) for x in path[:-1])) tilepath = [str(x) for x in path[:-1]]
tilepath = os.sep.join(tilepath)
name = str(path[-1]) name = str(path[-1])
batch.append((dest, name, self.imgformat, self.optimizeimg)) self.full_tiledir
batch.append((tilepath, name, self.imgformat, self.optimizeimg))
tiles += 1 tiles += 1
if tiles >= batch_size: if tiles >= batch_size:
tiles = 0 tiles = 0
@@ -410,11 +417,14 @@ class QuadtreeGen(object):
@catch_keyboardinterrupt @catch_keyboardinterrupt
def render_innertile_batch(batch): def render_innertile_batch(batch):
global child_quadtree
quadtree = child_quadtree
count = 0 count = 0
#logging.debug("{0} working on batch of size {1}".format(os.getpid(),len(batch))) #logging.debug("{0} working on batch of size {1}".format(os.getpid(),len(batch)))
for job in batch: for job in batch:
count += 1 count += 1
render_innertile(job[0],job[1],job[2],job[3]) dest = quadtree.full_tiledir+os.sep+job[0]
render_innertile(dest,job[1],job[2],job[3])
return count return count
def render_innertile(dest, name, imgformat, optimizeimg): def render_innertile(dest, name, imgformat, optimizeimg):
@@ -481,11 +491,9 @@ def render_innertile(dest, name, imgformat, optimizeimg):
optimize_image(imgpath, imgformat, optimizeimg) optimize_image(imgpath, imgformat, optimizeimg)
@catch_keyboardinterrupt @catch_keyboardinterrupt
def render_worldtile_batch(batch): def render_worldtile_batch(batch):
global child_quadtree global child_quadtree
return render_worldtile_batch_(child_quadtree, batch) quadtree = child_quadtree
def render_worldtile_batch_(quadtree, batch):
count = 0 count = 0
_get_chunks_in_range = quadtree._get_chunks_in_range _get_chunks_in_range = quadtree._get_chunks_in_range
#logging.debug("{0} working on batch of size {1}".format(os.getpid(),len(batch))) #logging.debug("{0} working on batch of size {1}".format(os.getpid(),len(batch)))
@@ -496,6 +504,7 @@ def render_worldtile_batch_(quadtree, batch):
rowstart = job[2] rowstart = job[2]
rowend = job[3] rowend = job[3]
path = job[4] path = job[4]
path = quadtree.full_tiledir+os.sep+path
# (even if tilechunks is empty, render_worldtile will delete # (even if tilechunks is empty, render_worldtile will delete
# existing images if appropriate) # existing images if appropriate)
# And uses these chunks # And uses these chunks

View File

@@ -70,9 +70,10 @@ class World(object):
def __init__(self, worlddir, useBiomeData=False,regionlist=None): def __init__(self, worlddir, useBiomeData=False,regionlist=None):
self.worlddir = worlddir self.worlddir = worlddir
self.useBiomeData = useBiomeData self.useBiomeData = useBiomeData
#find region files, or load the region list #find region files, or load the region list
#this also caches all the region file header info #this also caches all the region file header info
logging.info("Scanning regions")
regionfiles = {} regionfiles = {}
regions = {} regions = {}
for x, y, regionfile in self._iterate_regionfiles(): for x, y, regionfile in self._iterate_regionfiles():
@@ -82,6 +83,7 @@ class World(object):
regionfiles[(x,y)] = (x,y,regionfile) regionfiles[(x,y)] = (x,y,regionfile)
self.regionfiles = regionfiles self.regionfiles = regionfiles
self.regions = regions self.regions = regions
logging.debug("Done scanning regions")
# figure out chunk format is in use # figure out chunk format is in use
# if not mcregion, error out early # if not mcregion, error out early