0

Revert "Merge remote-tracking branch 'exhuma/master', PR #963"

This reverts commit e26727943f, reversing
changes made to 7bbb077704.
This commit is contained in:
Aaron Griffith
2013-12-02 07:40:00 -05:00
parent a8a2a191b8
commit df732bfa25
11 changed files with 165 additions and 219 deletions

View File

@@ -42,8 +42,6 @@ from overviewer_core import configParser, tileset, assetmanager, dispatcher
from overviewer_core import cache
from overviewer_core import observer
LOG = logging.getLogger('overviewer_core')
helptext = """
%prog [--rendermodes=...] [options] <World> <Output Dir>
%prog --config=<config file> [options]"""
@@ -161,14 +159,14 @@ def main():
from overviewer_core.textures import Textures
tex = Textures()
LOG.info("Looking for a few common texture files...")
logging.info("Looking for a few common texture files...")
try:
f = tex.find_file("assets/minecraft/textures/blocks/sandstone_top.png", verbose=True)
f = tex.find_file("assets/minecraft/textures/blocks/grass_top.png", verbose=True)
f = tex.find_file("assets/minecraft/textures/blocks/diamond_ore.png", verbose=True)
f = tex.find_file("assets/minecraft/textures/blocks/planks_acacia.png", verbose=True)
except IOError:
LOG.error("Could not find any texture files.")
logging.error("Could not find any texture files.")
return 1
return 0
@@ -188,7 +186,7 @@ def main():
else:
# more helpful message for users who know what they're doing
LOG.error("You must either specify --config or give me a world directory and output directory")
logging.error("You must either specify --config or give me a world directory and output directory")
parser.print_help()
list_worlds()
return 1
@@ -205,12 +203,12 @@ def main():
print("worlds['myworld'] = %r" % args[0])
print("outputdir = %r" % (args[1] if len(args) > 1 else "/path/to/output"))
print()
LOG.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()
return 1
if not options.config and len(args) < 2:
LOG.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()
return 1
if not options.config and len(args) > 2:
@@ -220,10 +218,10 @@ def main():
if not os.path.exists(args[start]):
for end in range(start+1, len(args)+1):
if os.path.exists(" ".join(args[start:end])):
LOG.warning("It looks like you meant to specify \"%s\" as your world dir or your output\n\
logging.warning("It looks like you meant to specify \"%s\" as your world dir or your output\n\
dir but you forgot to put quotes around the directory, since it contains spaces." % " ".join(args[start:end]))
return 1
LOG.error("Too many command line arguments")
logging.error("Too many command line arguments")
parser.print_help()
return 1
@@ -235,8 +233,8 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
if not options.config:
# No config file mode.
worldpath, destdir = map(os.path.expanduser, args)
LOG.debug("Using %r as the world directory", worldpath)
LOG.debug("Using %r as the output directory", destdir)
logging.debug("Using %r as the world directory", worldpath)
logging.debug("Using %r as the output directory", destdir)
mw_parser.set_config_item("worlds", {'world': worldpath})
mw_parser.set_config_item("outputdir", destdir)
@@ -257,7 +255,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
else:
if options.rendermodes:
LOG.error("You cannot specify --rendermodes if you give a config file. Configure your rendermodes in the config file instead")
logging.error("You cannot specify --rendermodes if you give a config file. Configure your rendermodes in the config file instead")
parser.print_help()
return 1
@@ -266,7 +264,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
mw_parser.parse(os.path.expanduser(options.config))
except configParser.MissingConfigException as e:
# this isn't a "bug", so don't print scary traceback
LOG.error(str(e))
logging.error(str(e))
util.nice_exit(1)
# Add in the command options here, perhaps overriding values specified in
@@ -279,16 +277,16 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
config = mw_parser.get_validated_config()
except Exception as ex:
if options.verbose:
LOG.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.")
else: # no need to print scary traceback! just
LOG.error("An error was encountered with your configuration.")
LOG.error(str(ex))
logging.error("An error was encountered with your configuration.")
logging.error(str(ex))
return 1
if options.check_terrain: # we are already in the "if configfile" branch
LOG.info("Looking for a few common texture files...")
logging.info("Looking for a few common texture files...")
for render_name, render in config['renders'].iteritems():
LOG.info("Looking at render %r", render_name)
logging.info("Looking at render %r", render_name)
# find or create the textures object
texopts = util.dict_subset(render, ["texturepath"])
@@ -302,8 +300,8 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
############################################################
# Final validation steps and creation of the destination directory
LOG.info("Welcome to Minecraft Overviewer!")
LOG.debug("Current log level: {0}".format(LOG.level))
logging.info("Welcome to Minecraft Overviewer!")
logging.debug("Current log level: {0}".format(logging.getLogger().level))
# Override some render configdict options depending on one-time command line
# modifiers
@@ -312,26 +310,26 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
bool(options.checktiles) +
bool(options.notilechecks)
) > 1:
LOG.error("You cannot specify more than one of --forcerender, "+
logging.error("You cannot specify more than one of --forcerender, "+
"--check-tiles, and --no-tile-checks. These options conflict.")
parser.print_help()
return 1
if options.forcerender:
LOG.info("Forcerender mode activated. ALL tiles will be rendered")
logging.info("Forcerender mode activated. ALL tiles will be rendered")
for render in config['renders'].itervalues():
render['renderchecks'] = 2
elif options.checktiles:
LOG.info("Checking all tiles for updates manually.")
logging.info("Checking all tiles for updates manually.")
for render in config['renders'].itervalues():
render['renderchecks'] = 1
elif options.notilechecks:
LOG.info("Disabling all tile mtime checks. Only rendering tiles "+
logging.info("Disabling all tile mtime checks. Only rendering tiles "+
"that need updating since last render")
for render in config['renders'].itervalues():
render['renderchecks'] = 0
if not config['renders']:
LOG.error("You must specify at least one render in your config file. See the docs if you're having trouble")
logging.error("You must specify at least one render in your config file. See the docs if you're having trouble")
return 1
#####################
@@ -342,7 +340,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
try:
worldpath = config['worlds'][render['world']]
except KeyError:
LOG.error("Render %s's world is '%s', but I could not find a corresponding entry in the worlds dictionary.",
logging.error("Render %s's world is '%s', but I could not find a corresponding entry in the worlds dictionary.",
rname, render['world'])
return 1
render['worldname_orig'] = render['world']
@@ -359,23 +357,23 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
try:
renderLink = config['renders'][x]
except KeyError:
LOG.error("Render %s's overlay is '%s', but I could not find a corresponding entry in the renders dictionary.",
logging.error("Render %s's overlay is '%s', but I could not find a corresponding entry in the renders dictionary.",
rname, x)
return 1
else:
LOG.error("Render %s's overlay contains itself.", rname)
logging.error("Render %s's overlay contains itself.", rname)
return 1
destdir = config['outputdir']
if not destdir:
LOG.error("You must specify the output directory in your config file.")
LOG.error("e.g. outputdir = '/path/to/outputdir'")
logging.error("You must specify the output directory in your config file.")
logging.error("e.g. outputdir = '/path/to/outputdir'")
return 1
if not os.path.exists(destdir):
try:
os.mkdir(destdir)
except OSError:
LOG.exception("Could not create the output directory.")
logging.exception("Could not create the output directory.")
return 1
########################################################################
@@ -387,7 +385,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
# If we've been asked to update web assets, do that and then exit
if options.update_web_assets:
assetMrg.output_noconfig()
LOG.info("Web assets have been updated")
logging.info("Web assets have been updated")
return 0
# The changelist support.
@@ -397,7 +395,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
path = render['changelist']
if path not in changelists:
out = open(path, "w")
LOG.debug("Opening changelist %s (%s)", out, out.fileno())
logging.debug("Opening changelist %s (%s)", out, out.fileno())
changelists[path] = out
else:
out = changelists[path]
@@ -419,7 +417,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
renders = config['renders']
for render_name, render in renders.iteritems():
LOG.debug("Found the following render thing: %r", render)
logging.debug("Found the following render thing: %r", render)
# find or create the world object
try:
@@ -441,13 +439,13 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
tex = texcache[texopts_key]
try:
LOG.debug("Asking for regionset %r" % render['dimension'][1])
logging.debug("Asking for regionset %r" % render['dimension'][1])
rset = w.get_regionset(render['dimension'][1])
except IndexError:
LOG.error("Sorry, I can't find anything to render! Are you sure there are .mca files in the world directory?")
logging.error("Sorry, I can't find anything to render! Are you sure there are .mca files in the world directory?")
return 1
if rset == None: # indicates no such dimension was found:
LOG.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'][0], render_name)
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'][0], render_name)
return 1
#################
@@ -467,7 +465,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
# object
if (render['northdirection'] > 0):
rset = world.RotatedRegionSet(rset, render['northdirection'])
LOG.debug("Using RegionSet %r", rset)
logging.debug("Using RegionSet %r", rset)
###############################
# Do the final prep and create the TileSet object
@@ -501,13 +499,13 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
assetMrg.finalize(tilesets)
for out in changelists.itervalues():
LOG.debug("Closing %s (%s)", out, out.fileno())
logging.debug("Closing %s (%s)", out, out.fileno())
out.close()
if config['processes'] == 1:
LOG.debug("Final cache stats:")
logging.debug("Final cache stats:")
for c in caches:
LOG.debug("\t%s: %s hits, %s misses", c.__class__.__name__, c.hits, c.misses)
logging.debug("\t%s: %s hits, %s misses", c.__class__.__name__, c.hits, c.misses)
if options.pid:
os.remove(options.pid)
@@ -552,10 +550,10 @@ if __name__ == "__main__":
util.nice_exit(ret)
except textures.TextureException as e:
# this isn't a "bug", so don't print scary traceback
LOG.error(str(e))
logging.error(str(e))
util.nice_exit(1)
except Exception as e:
LOG.exception("""An error has occurred. This may be a bug. Please let us know!
logging.exception("""An error has occurred. This may be a bug. Please let us know!
See http://docs.overviewer.org/en/latest/index.html#help
This is the error that occurred:""")