0

modified to support freezing

This commit is contained in:
Andrew Brown
2010-09-28 23:04:21 -04:00
parent 81d86d6b8b
commit 7a696fcee0
4 changed files with 36 additions and 2 deletions

View File

@@ -140,4 +140,5 @@ def list_worlds():
if __name__ == "__main__": if __name__ == "__main__":
multiprocessing.freeze_support()
main() main()

View File

@@ -26,6 +26,8 @@ import json
from PIL import Image from PIL import Image
import util
""" """
This module has routines related to generating a quadtree of tiles This module has routines related to generating a quadtree of tiles
@@ -114,7 +116,7 @@ class QuadtreeGen(object):
def write_html(self, zoomlevel, imgformat): def write_html(self, zoomlevel, imgformat):
"""Writes out index.html""" """Writes out index.html"""
templatepath = os.path.join(os.path.split(__file__)[0], "template.html") templatepath = os.path.join(util.get_program_path(), "template.html")
html = open(templatepath, 'r').read() html = open(templatepath, 'r').read()
html = html.replace( html = html.replace(

View File

@@ -23,6 +23,8 @@ import math
import numpy import numpy
from PIL import Image, ImageEnhance from PIL import Image, ImageEnhance
import util
def _find_file(filename, mode="rb"): def _find_file(filename, mode="rb"):
"""Searches for the given file and returns an open handle to it. """Searches for the given file and returns an open handle to it.
This searches the following locations in this order: This searches the following locations in this order:
@@ -39,7 +41,7 @@ def _find_file(filename, mode="rb"):
* The program dir / textures * The program dir / textures
""" """
programdir = os.path.dirname(__file__) programdir = util.get_program_path()
path = os.path.join(programdir, filename) path = os.path.join(programdir, filename)
if os.path.exists(path): if os.path.exists(path):
return open(path, mode) return open(path, mode)

29
util.py Normal file
View File

@@ -0,0 +1,29 @@
# This file is part of the Minecraft Overviewer.
#
# Minecraft Overviewer is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# Minecraft Overviewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
"""
Misc utility routines used by multiple files that don't belong anywhere else
"""
import imp
import os
import os.path
import sys
def get_program_path():
if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
return os.path.dirname(sys.executable)
else:
return os.path.dirname(sys.argv[0])