Index: Extensions/mouseposition/mouseposition.py =================================================================== --- Extensions/mouseposition/mouseposition.py (revision 2868) +++ Extensions/mouseposition/mouseposition.py (working copy) @@ -98,11 +98,17 @@ canvas.SelectTool(MousePositionTool(canvas, context)) +import sys +print "sys loaded" +from Thuban.Lib.fileutil import get_thuban_dir; +print "loaded" # locator executed as an tool/extension to Thuban -iconfile = os.path.join(os.path.abspath(Thuban.__path__[0]), - "..", "Resources", "Bitmaps", "identify") -iconfile = os.path.join(os.path.abspath(os.path.dirname(__file__)), +if hasattr(sys, 'frozen'): + iconfile = str(os.path.join(os.path.abspath(get_thuban_dir()), 'Extensions', 'mouseposition', 'position')) +else: + iconfile = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'position') + registry.Add(ToolCommand("mouse_position_tool", "Mouse Position Tool", mouse_position_tool, icon = iconfile, helptext = "Collect mouse click coordinates in a dialog", Index: Thuban/__init__.py =================================================================== --- Thuban/__init__.py (revision 2868) +++ Thuban/__init__.py (working copy) @@ -8,6 +8,7 @@ # Read the file COPYING coming with Thuban for details. import os +import sys # Thuban Message Translation # @@ -42,9 +43,9 @@ # Thedirectory holding the translation files (actually they're in # language specific subdirectories of _message_dir) -_message_dir = os.path.join(os.path.dirname(__file__), os.pardir, "Resources", - "Locale") + + def _(s): """Return a localized version of the the string s @@ -56,6 +57,9 @@ """ return _translation_function(s) +from Lib.fileutil import get_thuban_dir; +_message_dir = os.path.join(get_thuban_dir(), "Resources", "Locale") + def gettext_identity(s): """Default gettext implementation which returns the string as is""" return s Index: Thuban/Lib/fileutil.py =================================================================== --- Thuban/Lib/fileutil.py (revision 2868) +++ Thuban/Lib/fileutil.py (working copy) @@ -13,6 +13,7 @@ import os import os.path +import sys from tempfile import mktemp from string import join @@ -159,7 +160,6 @@ Under posix systems use the os.expanduser() method. Under Win32 try to read the "Explorer/Shell Folders/" value "AppData". """ - if os.name == 'posix': dir = os.path.expanduser("~/.thuban") if not os.path.isdir(dir): @@ -191,13 +191,24 @@ dir = os.path.join(guess, "thuban") if not os.path.isdir(dir): os.mkdir(dir) + + return str(dir) - return dir - else: raise RuntimeError(_("No implementation of get_application_dir" " available for platform") + os.name) +def get_thuban_dir(): + """Determine the path to the where the Thuban directory is stored + + This method is needed to solve problems when the application is frozen + """ + if hasattr(sys, 'frozen'): + res_path = os.path.normpath(os.path.dirname(sys.executable)) + else: + res_path = os.path.normpath(os.path.join(os.path.dirname(__file__), os.pardir ,os.pardir)) + return res_path + # bind the appropriate version of relative_filename for the platform # we're currently running on. if os.name == "posix": Index: Thuban/Model/resource.py =================================================================== --- Thuban/Model/resource.py (revision 2868) +++ Thuban/Model/resource.py (working copy) @@ -20,16 +20,15 @@ import Thuban from Thuban import _ -from Thuban.Lib.fileutil import get_application_dir +from Thuban.Lib.fileutil import get_application_dir, get_thuban_dir from Thuban.Model.xmlreader import XMLReader from Thuban.Model.xmlwriter import XMLWriter from Thuban.Model.proj import Projection, ProjFile from xml.sax import SAXParseException -projdir = \ - os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Projections") +projdir = os.path.join(get_thuban_dir(), "Resources", "Projections") PROJ_EXT = ".proj" Index: Thuban/UI/application.py =================================================================== --- Thuban/UI/application.py (revision 2868) +++ Thuban/UI/application.py (working copy) @@ -105,6 +105,38 @@ logging.exception(_("Cannot import the thuban_cfg module.")) logging.info(_("Trying to read ~/.thuban/thubanstart.py.")) + try: + import Extensions.gns2shp + except: + sys.stderr.write('Cannot load gns2shp') + try: + import Extensions.umn_mapserver + except: + sys.stderr.write('Cannot load umn_mapserver') + try: + import Extensions.wms + except: + sys.stderr.write('Cannot load wms') + try: + import Extensions.bboxdump + except: + sys.stderr.write('Cannot load bboxdump') + try: + import Extensions.mouseposition + except: + sys.stderr.write('Cannot load mouseposition') + try: + import Extensions.profiling + except: + sys.stderr.write('Cannot load profiling') + try: + import Extensions.svgexport + except: + sys.stderr.write('Cannot load svgexport') + try: + import Extensions.ogr + except: + sys.stderr.write('Cannot load ogr') dir = get_application_dir() if os.path.isdir(dir): sys.path.append(dir) @@ -115,7 +147,7 @@ try: if tb.tb_next is not None: # The ImportError exception was raised from - # inside the thubanstart module. + # inside the thubanstart module. sys.stderr.write(_("Cannot import the thubanstart" " module\n")) traceback.print_exc(None, sys.stderr)