diff --git a/gmap.py b/gmap.py index 00c7836..7d3f165 100755 --- a/gmap.py +++ b/gmap.py @@ -140,4 +140,5 @@ def list_worlds(): if __name__ == "__main__": + multiprocessing.freeze_support() main() diff --git a/quadtree.py b/quadtree.py index 553164e..161cb43 100644 --- a/quadtree.py +++ b/quadtree.py @@ -26,6 +26,8 @@ import json from PIL import Image +import util + """ This module has routines related to generating a quadtree of tiles @@ -114,7 +116,7 @@ class QuadtreeGen(object): def write_html(self, zoomlevel, imgformat): """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 = html.replace( diff --git a/textures.py b/textures.py index 966dee4..8d34b03 100644 --- a/textures.py +++ b/textures.py @@ -23,6 +23,8 @@ import math import numpy from PIL import Image, ImageEnhance +import util + def _find_file(filename, mode="rb"): """Searches for the given file and returns an open handle to it. This searches the following locations in this order: @@ -39,7 +41,7 @@ def _find_file(filename, mode="rb"): * The program dir / textures """ - programdir = os.path.dirname(__file__) + programdir = util.get_program_path() path = os.path.join(programdir, filename) if os.path.exists(path): return open(path, mode) diff --git a/util.py b/util.py new file mode 100644 index 0000000..46d1639 --- /dev/null +++ b/util.py @@ -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 . + +""" +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])