From fae67de9f0fb156b5a3d2408ab3431130aab9ccc Mon Sep 17 00:00:00 2001 From: Alex Headley Date: Sat, 19 Mar 2011 14:28:19 -0400 Subject: [PATCH] fixed some bugs in the validateRegion script --- contrib/validateRegionFile.py | 45 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/contrib/validateRegionFile.py b/contrib/validateRegionFile.py index 1e5320a..34ec1fe 100644 --- a/contrib/validateRegionFile.py +++ b/contrib/validateRegionFile.py @@ -12,15 +12,15 @@ import re import os.path import logging -# sys.path wrangling, so we can access Overviewer code -overviewer_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] -sys.path.insert(0, overviewer_dir) -import nbt -import chunk -import quadtree def main(): + # sys.path wrangling, so we can access Overviewer code + overviewer_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] + sys.path.insert(0, overviewer_dir) + import nbt + #import chunk + #import quadtree parser = OptionParser(usage=usage, description=description) parser.add_option("-r", "--regions", dest="regiondir", help="Use path to the regions instead of a list of files") parser.add_option("-v", dest="verbose", action="store_true", help="Lists why a chunk in a region failed") @@ -46,41 +46,56 @@ def main(): chunk_pass = 0 chunk_total = 0 if not os.path.exists(regionfile): - print("Region:%s Passed %s/%s"%(shortname,chunk_pass,chunk_total)) + print("File not found: %s"%( regionfile)) + #print("Region:%s Passed %s/%s"%(shortname,chunk_pass,chunk_total)) continue try: mcr = nbt.load_region(regionfile) except IOError, e: - if options.verbose: + if opt.verbose: print("Error opening regionfile. It may be corrupt. %s"%( e)) + continue if mcr is not None: try: chunks = mcr.get_chunk_info(False) except IOError, e: - if options.verbose: + if opt.verbose: print("Error opening regionfile(bad header info). It may be corrupt. %s"%( e)) chunks = [] + continue + except Exception, e: + if opt.verbose: + print("Error opening regionfile (%s): %s"%( regionfile,e)) + continue for x, y in chunks: chunk_total += 1 - #try: - chunk_data = mcr.load_chunk(x, y) + try: + chunk_data = mcr.load_chunk(x, y) + except Exception, e: + if opt.verbose: + print("Error reading chunk (%i,%i): %s"%(x,y,e)) + continue if chunk_data is None: - if options.verbose: + if opt.verbose: print("Chunk %s:%s is unexpectedly empty"%(x, y)) + continue else: try: processed = chunk_data.read_all() if processed == []: - if options.verbose: + if opt.verbose: print("Chunk %s:%s is an unexpectedly empty set"%(x, y)) + continue else: chunk_pass += 1 except Exception, e: - if options.verbose: + if opt.verbose: print("Error opening chunk (%i, %i) It may be corrupt. %s"%( x, y, e)) + continue else: - if options.verbose: + if opt.verbose: print("Error opening regionfile.") + continue print("Region:%s Passed %s/%s"%(shortname,chunk_pass,chunk_total)) if __name__ == "__main__":