Fixed: Log the exception in materials.py when pkg_resources fails to load a yaml file.

This commit is contained in:
David Vierra 2012-10-29 21:51:44 -10:00
parent 03c6baa42d
commit 6cde2003f4

View File

@ -156,7 +156,11 @@ class MCMaterials(object):
f = pkg_resources.resource_stream(__name__, filename) f = pkg_resources.resource_stream(__name__, filename)
except (ImportError, IOError): except (ImportError, IOError):
root = os.environ.get("PYMCLEVEL_YAML_ROOT", "pymclevel") # fall back to cwd as last resort root = os.environ.get("PYMCLEVEL_YAML_ROOT", "pymclevel") # fall back to cwd as last resort
f = file(join(root, filename)) path = join(root, filename)
log.exception("Failed to read %s using pkg_resources. Trying %s instead." % (filename, path))
f = file(path)
try: try:
info(u"Loading block info from %s", f) info(u"Loading block info from %s", f)
blockyaml = yaml.load(f) blockyaml = yaml.load(f)