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

@@ -29,9 +29,6 @@ import functools
import util
from c_overviewer import alpha_over
LOG = logging.getLogger(__name__)
class TextureException(Exception):
"To be thrown when a texture is not found."
pass
@@ -148,7 +145,7 @@ class Textures(object):
'environment/'.
"""
if verbose: LOG.info("Starting search for {0}".format(filename))
if verbose: logging.info("Starting search for {0}".format(filename))
# a list of subdirectories to search for a given file,
# after the obvious '.'
@@ -181,7 +178,7 @@ class Textures(object):
if os.path.isdir(self.find_file_local_path):
path = search_dir(self.find_file_local_path)
if path:
if verbose: LOG.info("Found %s in '%s'", filename, path)
if verbose: logging.info("Found %s in '%s'", filename, path)
return open(path, mode)
elif os.path.isfile(self.find_file_local_path):
# Must be a resource pack. Look for the requested file within
@@ -193,7 +190,7 @@ class Textures(object):
# pack.getinfo() will raise KeyError if the file is
# not found.
pack.getinfo(packfilename)
if verbose: LOG.info("Found %s in '%s'", packfilename, self.find_file_local_path)
if verbose: logging.info("Found %s in '%s'", packfilename, self.find_file_local_path)
return pack.open(packfilename)
except (KeyError, IOError):
pass
@@ -211,24 +208,24 @@ class Textures(object):
# If we haven't returned at this point, then the requested file was NOT
# found in the user-specified texture path or resource pack.
if verbose: LOG.info("Did not find the file in specified texture path")
if verbose: logging.info("Did not find the file in specified texture path")
# Look in the location of the overviewer executable for the given path
programdir = util.get_program_path()
path = search_dir(programdir)
if path:
if verbose: LOG.info("Found %s in '%s'", filename, path)
if verbose: logging.info("Found %s in '%s'", filename, path)
return open(path, mode)
if sys.platform.startswith("darwin"):
path = search_dir("/Applications/Minecraft")
if path:
if verbose: LOG.info("Found %s in '%s'", filename, path)
if verbose: logging.info("Found %s in '%s'", filename, path)
return open(path, mode)
if verbose: LOG.info("Did not find the file in overviewer executable directory")
if verbose: LOG.info("Looking for installed minecraft jar files...")
if verbose: logging.info("Did not find the file in overviewer executable directory")
if verbose: logging.info("Looking for installed minecraft jar files...")
# Find an installed minecraft client jar and look in it for the texture
# file we need.
@@ -245,7 +242,7 @@ class Textures(object):
try:
versions = os.listdir(versiondir)
if verbose: LOG.info("Found these versions: {0}".format(versions))
if verbose: logging.info("Found these versions: {0}".format(versions))
except OSError:
# Directory doesn't exist? Ignore it. It will find no versions and
# fall through the checks below to the error at the bottom of the
@@ -274,7 +271,7 @@ class Textures(object):
most_recent_version = versionparts
if most_recent_version != [0,0,0]:
if verbose: LOG.info("Most recent version >=1.7.0: {0}. Searching it for the file...".format(most_recent_version))
if verbose: logging.info("Most recent version >=1.7.0: {0}. Searching it for the file...".format(most_recent_version))
jarname = ".".join(str(x) for x in most_recent_version)
jarpath = os.path.join(versiondir, jarname, jarname + ".jar")
@@ -284,15 +281,15 @@ class Textures(object):
for jarfilename in search_zip_paths:
try:
jar.getinfo(jarfilename)
if verbose: LOG.info("Found %s in '%s'", jarfilename, jarpath)
if verbose: logging.info("Found %s in '%s'", jarfilename, jarpath)
self.jar, self.jarpath = jar, jarpath
return jar.open(jarfilename)
except (KeyError, IOError), e:
pass
if verbose: LOG.info("Did not find file {0} in jar {1}".format(filename, jarpath))
if verbose: logging.info("Did not find file {0} in jar {1}".format(filename, jarpath))
else:
if verbose: LOG.info("Did not find any non-snapshot minecraft jars >=1.7.0")
if verbose: logging.info("Did not find any non-snapshot minecraft jars >=1.7.0")
# Last ditch effort: look for the file is stored in with the overviewer
# installation. We include a few files that aren't included with Minecraft
@@ -300,16 +297,16 @@ class Textures(object):
# they were generated by the game and not stored as images. Nowdays I
# believe that's not true, but we still have a few files distributed
# with overviewer.
if verbose: LOG.info("Looking for texture in overviewer_core/data/textures")
if verbose: logging.info("Looking for texture in overviewer_core/data/textures")
path = search_dir(os.path.join(programdir, "overviewer_core", "data", "textures"))
if path:
if verbose: LOG.info("Found %s in '%s'", filename, path)
if verbose: logging.info("Found %s in '%s'", filename, path)
return open(path, mode)
elif hasattr(sys, "frozen") or imp.is_frozen("__main__"):
# windows special case, when the package dir doesn't exist
path = search_dir(os.path.join(programdir, "textures"))
if path:
if verbose: LOG.info("Found %s in '%s'", filename, path)
if verbose: logging.info("Found %s in '%s'", filename, path)
return open(path, mode)
raise TextureException("Could not find the textures while searching for '{0}'. Try specifying the 'texturepath' option in your config file.\nSet it to the path to a Minecraft Resource pack.\nAlternately, install the Minecraft client (which includes textures)\nAlso see <http://docs.overviewer.org/en/latest/running/#installing-the-textures>\n(Remember, this version of Overviewer requires a 1.7-compatible resource pack)\n(Also note that I won't automatically use snapshots; you'll have to use the texturepath option to use a snapshot jar)".format(filename))
@@ -415,7 +412,7 @@ class Textures(object):
try:
lightcolor = list(self.load_image("light_normal.png").getdata())
except Exception:
LOG.warning("Light color image could not be found.")
logging.warning("Light color image could not be found.")
lightcolor = None
self.lightcolor = lightcolor
return lightcolor