eminence / Minecraft-Overviewer

Render large resolution images of a Minecraft map with a Google Maps powered interface
GNU General Public License v3.0
13 stars 1 forks source link

Unhandled Exception in nbt.py: missing region file #1

Open cbarber opened 13 years ago

cbarber commented 13 years ago

Using the latest Beta 1.3 Minecraft server without mods and an upgraded McRegion world on FreeBSD 8.1-RELEASE.

I'm receiving an unhandled exception in nbt.py trying to open a region file that does not exist in my world directory. I believe this is caused by

chunk_path = self.world.get_region_path(self.chunkX - 1, self.chunkY)

when chunkX is negative.

IOError: [Errno 2] No such file or directory: '/home/cbarber/minecraft/world/region/r.-4.-2.mcr'

gmap.py output follows:

$ eminence-Minecraft-Overviewer/gmap.py --lighting --cachedir=/home/cbarber/minecraft/cache /home/cbarber/minecraft/world/ /home/cbarber/minecraft/map
2011-02-25 12:11:07,807 [INFO] Welcome to Minecraft Overviewer!
2011-02-25 12:11:07,808 [INFO] Notice: Not using biome data for tinting
2011-02-25 12:11:07,808 [ERROR] Sorry, Minecraft-Overviewer doesn't yet know how to read McRegion chunks
2011-02-25 12:11:07,811 [INFO] Scanning chunks
found 31 regions
region -3, -2  --> /home/cbarber/minecraft/world/region/r.-3.-2.mcr
region %d,%d will go from:
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
region -3, -1  --> /home/cbarber/minecraft/world/region/r.-3.-1.mcr
region %d,%d will go from:
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region -3, 0  --> /home/cbarber/minecraft/world/region/r.-3.0.mcr
region %d,%d will go from:
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region -3, 1  --> /home/cbarber/minecraft/world/region/r.-3.1.mcr
region %d,%d will go from:
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region -2, -3  --> /home/cbarber/minecraft/world/region/r.-2.-3.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
region -2, -2  --> /home/cbarber/minecraft/world/region/r.-2.-2.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
region -2, -1  --> /home/cbarber/minecraft/world/region/r.-2.-1.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region -2, 0  --> /home/cbarber/minecraft/world/region/r.-2.0.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region -2, 1  --> /home/cbarber/minecraft/world/region/r.-2.1.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region -1, -3  --> /home/cbarber/minecraft/world/region/r.-1.-3.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [-96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65]
region -1, -2  --> /home/cbarber/minecraft/world/region/r.-1.-2.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
region -1, -1  --> /home/cbarber/minecraft/world/region/r.-1.-1.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region -1, 0  --> /home/cbarber/minecraft/world/region/r.-1.0.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region -1, 1  --> /home/cbarber/minecraft/world/region/r.-1.1.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region -1, 2  --> /home/cbarber/minecraft/world/region/r.-1.2.mcr
region %d,%d will go from:
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
region 0, -2  --> /home/cbarber/minecraft/world/region/r.0.-2.mcr
region %d,%d will go from:
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
region 0, -1  --> /home/cbarber/minecraft/world/region/r.0.-1.mcr
region %d,%d will go from:
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region 0, 0  --> /home/cbarber/minecraft/world/region/r.0.0.mcr
region %d,%d will go from:
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region 0, 1  --> /home/cbarber/minecraft/world/region/r.0.1.mcr
region %d,%d will go from:
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region 0, 2  --> /home/cbarber/minecraft/world/region/r.0.2.mcr
region %d,%d will go from:
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
region 1, -1  --> /home/cbarber/minecraft/world/region/r.1.-1.mcr
region %d,%d will go from:
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region 1, 0  --> /home/cbarber/minecraft/world/region/r.1.0.mcr
region %d,%d will go from:
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region 1, 1  --> /home/cbarber/minecraft/world/region/r.1.1.mcr
region %d,%d will go from:
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region 2, -1  --> /home/cbarber/minecraft/world/region/r.2.-1.mcr
region %d,%d will go from:
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
region 2, 0  --> /home/cbarber/minecraft/world/region/r.2.0.mcr
region %d,%d will go from:
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region 2, 1  --> /home/cbarber/minecraft/world/region/r.2.1.mcr
region %d,%d will go from:
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region 3, 0  --> /home/cbarber/minecraft/world/region/r.3.0.mcr
region %d,%d will go from:
  [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
region 3, 1  --> /home/cbarber/minecraft/world/region/r.3.1.mcr
region %d,%d will go from:
  [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
region 1, 2  --> /home/cbarber/minecraft/world/region/r.1.2.mcr
region %d,%d will go from:
  [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
region -2, 2  --> /home/cbarber/minecraft/world/region/r.-2.2.mcr
region %d,%d will go from:
  [-64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33]
  [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]
region 3, -1  --> /home/cbarber/minecraft/world/region/r.3.-1.mcr
region %d,%d will go from:
  [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]
  [-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
2011-02-25 12:11:07,977 [INFO] 1/31744 chunks rendered
2011-02-25 12:11:07,978 [INFO] 2/31744 chunks rendered
2011-02-25 12:11:07,979 [INFO] 4/31744 chunks rendered
2011-02-25 12:11:07,979 [INFO] 5/31744 chunks rendered
2011-02-25 12:11:07,980 [INFO] 8/31744 chunks rendered
2011-02-25 12:11:07,981 [INFO] 10/31744 chunks rendered
Traceback (most recent call last):
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 173, in render_and_save
    return a.render_and_save(cave)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 524, in render_and_save
    img = self.chunk_render(cave=cave)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 648, in chunk_render
    left_blocks = self.left_blocks
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 309, in _load_left_blocks
    self._load_left()
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 297, in _load_left
    chunk_data = get_lvldata(chunk_path, self.chunkX - 1, self.chunkY)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 53, in get_lvldata
    d =  nbt.load_from_region(filename, x, y)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/nbt.py", line 25, in wrapper
    fileobj = open(fileobj, 'rb')
IOError: [Errno 2] No such file or directory: '/home/cbarber/minecraft/world/region/r.-4.-2.mcr'
Traceback (most recent call last):
  File "eminence-Minecraft-Overviewer/gmap.py", line 205, in 
    main()
  File "eminence-Minecraft-Overviewer/gmap.py", line 144, in main
    w.go(options.procs)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/world.py", line 253, in go
    self.chunkmap = self._render_chunks_async(chunks, procs)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/world.py", line 352, in _render_chunks_async
    result = chunk.render_and_save(chunkXY, self.cachedir, self, oldimg, queue=q)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 173, in render_and_save
    return a.render_and_save(cave)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 524, in render_and_save
    img = self.chunk_render(cave=cave)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 648, in chunk_render
    left_blocks = self.left_blocks
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 309, in _load_left_blocks
    self._load_left()
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 297, in _load_left
    chunk_data = get_lvldata(chunk_path, self.chunkX - 1, self.chunkY)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/chunk.py", line 53, in get_lvldata
    d =  nbt.load_from_region(filename, x, y)
  File "/usr/home/cbarber/minecraft/eminence-Minecraft-Overviewer/nbt.py", line 25, in wrapper
    fileobj = open(fileobj, 'rb')
IOError: [Errno 2] No such file or directory: '/home/cbarber/minecraft/world/region/r.-4.-2.mcr'

My fix was to check if the region file exists, otherwise return None, which should bubble up properly.

--- nbt.py.original     2011-02-25 12:18:12.000000000 -0500
+++ nbt.py      2011-02-25 12:15:59.000000000 -0500
@@ -22,6 +22,9 @@
 def _file_loader(func):
     def wrapper(fileobj, *args):
         if isinstance(fileobj, basestring):
+            if not os.path.isfile(fileobj):
+               return None
+
             # Is actually a filename
             fileobj = open(fileobj, 'rb')
         return func(fileobj, *args)

Currently running on 5000/31744 chunks so looks promising.

eminence commented 13 years ago

good catch, thanks. i think it would be faster to catch the exception, instead of checking path.isfile. I'll think about where the best place for that would be (either in nbt.py or in _load_left and _load_right of chunk.py). I'll push a fix tonight

cbarber commented 13 years ago

Confirmed that everything worked after the fix is in place.

I would advise against using the exception for two reasons:

You could keep an array of tuples or a custom object to store which regions exist. Then you could check if you're going out of bounds before trying to load the region. No file system check or exception.

I'm new to github and git so I'm not sure what the best procedure for helping here is. Would you prefer unified patches or fork/pull request?

eminence commented 13 years ago

when i suggested to use exceptions, i didn't mean to add "if not file exists, throw exception", but simply try to open() the file, and if it doesn't exist, catch the the exception (either in _file_loader or somewhere higher up). I think this will be faster since this will probably be a rare occurrence, but this may be a debatable point.

interestingly, i haven't been able to reproduce this bug. i've tried rendering several maps, and all run to completion without throwing this exception. as far as i can tell, this will only happen when chunkX,chunkY is right on the edge of a region, and so chunk_path = self.world.get_region_path(self.chunkX - 1, self.chunkY) returns a region that doesn't exist. (note that if chuckX, chunkY is in the middle of a region, chunk_path will always reference a valid region)

anyway, since you've tested your patch, i'll gladly accept it. i can either apply your patch and commit it on your behalf, or you can submit a pull request. normally i like pull requests, but since this change is so minor, it'll probably be easier for me to just apply the patch manually (unless you wan't the experience of submitting a pull request)

mbainter commented 13 years ago

I just ran into this same issue, just FYI

I am not a pythonista by any stretch, but I did give a shot at wrapping it in a try/except block and added in the logging module so I could see it happening. My output looks roughly like this:

2011-02-26 13:08:18,874 [INFO] 500/6144 chunks rendered 2011-02-26 13:12:04,570 [INFO] 1000/6144 chunks rendered 2011-02-26 13:12:14,323 [WARNING] Error Opening.../region/r.-2.-1.mcr 2011-02-26 13:12:14,332 [WARNING] Error Opening .../region/r.-2.-1.mcr ... 2011-02-26 13:19:22,155 [INFO] 2000/6144 chunks rendered

Patch: --- nbt.py.orig 2011-02-26 13:24:41.000000000 -0600 +++ nbt.py 2011-02-26 13:24:53.000000000 -0600 @@ -16,13 +16,18 @@ import gzip, zlib import struct import StringIO +import logging

 # decorator to handle filename or object as first parameter
 def _file_loader(func):
     def wrapper(fileobj, *args):
         if isinstance(fileobj, basestring):
             # Is actually a filename
 -            fileobj = open(fileobj, 'rb')
+            try:
+               fileobj = open(fileobj, 'rb')
+            except Exception, e:
+               logging.warning("Error Opening %s, continuing..." % fileobj);
+               return None
         return func(fileobj, *args)
     return wrapper