crude progress bar implementation
This commit is contained in:
@@ -40,6 +40,7 @@ from overviewer_core import textures
|
|||||||
from overviewer_core import optimizeimages, world
|
from overviewer_core import optimizeimages, world
|
||||||
from overviewer_core import configParser, tileset, assetmanager, dispatcher
|
from overviewer_core import configParser, tileset, assetmanager, dispatcher
|
||||||
from overviewer_core import cache
|
from overviewer_core import cache
|
||||||
|
from overviewer_core import progressbar
|
||||||
|
|
||||||
helptext = """
|
helptext = """
|
||||||
%prog [--rendermodes=...] [options] <World> <Output Dir>
|
%prog [--rendermodes=...] [options] <World> <Output Dir>
|
||||||
@@ -53,7 +54,7 @@ def main():
|
|||||||
cpus = multiprocessing.cpu_count()
|
cpus = multiprocessing.cpu_count()
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
cpus = 1
|
cpus = 1
|
||||||
|
|
||||||
#avail_rendermodes = c_overviewer.get_render_modes()
|
#avail_rendermodes = c_overviewer.get_render_modes()
|
||||||
avail_north_dirs = ['lower-left', 'upper-left', 'upper-right', 'lower-right', 'auto']
|
avail_north_dirs = ['lower-left', 'upper-left', 'upper-right', 'lower-right', 'auto']
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ def main():
|
|||||||
# Options that only apply to the config-less render usage
|
# Options that only apply to the config-less render usage
|
||||||
parser.add_option("--rendermodes", dest="rendermodes", action="store",
|
parser.add_option("--rendermodes", dest="rendermodes", action="store",
|
||||||
help="If you're not using a config file, specify which rendermodes to render with this option. This is a comma-separated list.")
|
help="If you're not using a config file, specify which rendermodes to render with this option. This is a comma-separated list.")
|
||||||
|
|
||||||
# Useful one-time render modifiers:
|
# Useful one-time render modifiers:
|
||||||
parser.add_option("--forcerender", dest="forcerender", action="store_true",
|
parser.add_option("--forcerender", dest="forcerender", action="store_true",
|
||||||
help="Force re-rendering the entire map.")
|
help="Force re-rendering the entire map.")
|
||||||
@@ -140,7 +141,7 @@ def main():
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
list_worlds()
|
list_worlds()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# This section does some sanity checking on the command line options passed
|
# This section does some sanity checking on the command line options passed
|
||||||
# in. It checks to see if --config was given that no worldname/destdir were
|
# in. It checks to see if --config was given that no worldname/destdir were
|
||||||
@@ -156,7 +157,7 @@ def main():
|
|||||||
logging.error("Cannot specify both --config AND a world + output directory on the command line.")
|
logging.error("Cannot specify both --config AND a world + output directory on the command line.")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not options.config and len(args) < 2:
|
if not options.config and len(args) < 2:
|
||||||
logging.error("You must specify both the world directory and an output directory")
|
logging.error("You must specify both the world directory and an output directory")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
@@ -185,7 +186,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
worldpath, destdir = map(os.path.expanduser, args)
|
worldpath, destdir = map(os.path.expanduser, args)
|
||||||
logging.debug("Using %r as the world directory", worldpath)
|
logging.debug("Using %r as the world directory", worldpath)
|
||||||
logging.debug("Using %r as the output directory", destdir)
|
logging.debug("Using %r as the output directory", destdir)
|
||||||
|
|
||||||
mw_parser.set_config_item("worlds", {'world': worldpath})
|
mw_parser.set_config_item("worlds", {'world': worldpath})
|
||||||
mw_parser.set_config_item("outputdir", destdir)
|
mw_parser.set_config_item("outputdir", destdir)
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
logging.exception("An error was encountered with your configuration. See the info below.")
|
logging.exception("An error was encountered with your configuration. See the info below.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Final validation steps and creation of the destination directory
|
# Final validation steps and creation of the destination directory
|
||||||
@@ -335,7 +336,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
w = world.World(render['world'])
|
w = world.World(render['world'])
|
||||||
worldcache[render['world']] = w
|
worldcache[render['world']] = w
|
||||||
|
|
||||||
# find or create the textures object
|
# find or create the textures object
|
||||||
texopts = util.dict_subset(render, ["texturepath", "bgcolor", "northdirection"])
|
texopts = util.dict_subset(render, ["texturepath", "bgcolor", "northdirection"])
|
||||||
texopts_key = tuple(texopts.items())
|
texopts_key = tuple(texopts.items())
|
||||||
@@ -363,12 +364,12 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
# If a crop is requested, wrap the regionset here
|
# If a crop is requested, wrap the regionset here
|
||||||
if "crop" in render:
|
if "crop" in render:
|
||||||
rset = world.CroppedRegionSet(rset, *render['crop'])
|
rset = world.CroppedRegionSet(rset, *render['crop'])
|
||||||
|
|
||||||
# If this is to be a rotated regionset, wrap it in a RotatedRegionSet
|
# If this is to be a rotated regionset, wrap it in a RotatedRegionSet
|
||||||
# object
|
# object
|
||||||
if (render['northdirection'] > 0):
|
if (render['northdirection'] > 0):
|
||||||
rset = world.RotatedRegionSet(rset, render['northdirection'])
|
rset = world.RotatedRegionSet(rset, render['northdirection'])
|
||||||
logging.debug("Using RegionSet %r", rset)
|
logging.debug("Using RegionSet %r", rset)
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Do the final prep and create the TileSet object
|
# Do the final prep and create the TileSet object
|
||||||
@@ -389,7 +390,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
|
|
||||||
# Output initial static data and configuration
|
# Output initial static data and configuration
|
||||||
assetMrg.initialize(tilesets)
|
assetMrg.initialize(tilesets)
|
||||||
|
|
||||||
# multiprocessing dispatcher
|
# multiprocessing dispatcher
|
||||||
if config['processes'] == 1:
|
if config['processes'] == 1:
|
||||||
dispatch = dispatcher.Dispatcher()
|
dispatch = dispatcher.Dispatcher()
|
||||||
@@ -407,7 +408,17 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
percent = int(100* completed/total)
|
percent = int(100* completed/total)
|
||||||
logging.info("Rendered %d of %d. %d%% complete", completed, total, percent)
|
logging.info("Rendered %d of %d. %d%% complete", completed, total, percent)
|
||||||
|
|
||||||
dispatch.render_all(tilesets, print_status)
|
def update_pbar(phase, completed, total):
|
||||||
|
if total is None or total == 0:
|
||||||
|
print_status(phase, completed, total)
|
||||||
|
else:
|
||||||
|
pbar = progressbar.ProgressBar(
|
||||||
|
widgets=['Rendering: ', progressbar.FractionWidget(), ' (',
|
||||||
|
progressbar.Percentage(), ') ',
|
||||||
|
progressbar.Bar(left='[', right=']'), ' ', progressbar.ETA()],
|
||||||
|
maxval=total).start().update(completed)
|
||||||
|
|
||||||
|
dispatch.render_all(tilesets, update_pbar)
|
||||||
dispatch.close()
|
dispatch.close()
|
||||||
|
|
||||||
assetMrg.finalize(tilesets)
|
assetMrg.finalize(tilesets)
|
||||||
@@ -425,7 +436,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
|
|
||||||
def list_worlds():
|
def list_worlds():
|
||||||
"Prints out a brief summary of saves found in the default directory"
|
"Prints out a brief summary of saves found in the default directory"
|
||||||
print
|
print
|
||||||
worlds = world.get_worlds()
|
worlds = world.get_worlds()
|
||||||
if not worlds:
|
if not worlds:
|
||||||
print 'No world saves found in the usual place'
|
print 'No world saves found in the usual place'
|
||||||
|
|||||||
Reference in New Issue
Block a user