[Thuban-commits] r2875 - in trunk/thuban: . Thuban Thuban/Lib Thuban/Model Thuban/UI

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 18 16:12:23 CEST 2009


Author: dpinte
Date: 2009-05-18 16:12:22 +0200 (Mon, 18 May 2009)
New Revision: 2875

Modified:
   trunk/thuban/ChangeLog
   trunk/thuban/Thuban/Lib/fileutil.py
   trunk/thuban/Thuban/Model/resource.py
   trunk/thuban/Thuban/UI/__init__.py
   trunk/thuban/Thuban/UI/application.py
   trunk/thuban/Thuban/__init__.py
   trunk/thuban/setup.py
Log:
2009-05-18 Didrik Pinte <dpinte at dipole-consulting.com>

  * Thuban/UI/__init__.py, application.py : bugfix for wxpython 2.8
  * setup.py : removed some unneeded dll's from wxproj compilation
  * Thuban/Lib/fileutil.py : added get_thuban_dir() method managing freezed path's
  * Thuban/__init__.py, Thuban/Model/resource.py : uses the new get_thuban_dir() method

Modified: trunk/thuban/ChangeLog
===================================================================
--- trunk/thuban/ChangeLog	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/ChangeLog	2009-05-18 14:12:22 UTC (rev 2875)
@@ -1,5 +1,12 @@
 2009-05-18 Didrik Pinte <dpinte at dipole-consulting.com>
 
+  * Thuban/UI/__init__.py, application.py : bugfix for wxpython 2.8
+  * setup.py : removed some unneeded dll's from wxproj compilation
+  * Thuban/Lib/fileutil.py : added get_thuban_dir() method managing freezed path's
+  * Thuban/__init__.py, Thuban/Model/resource.py : uses the new get_thuban_dir() method
+
+2009-05-18 Didrik Pinte <dpinte at dipole-consulting.com>
+
   * setup.py : updated to run with wxpython 2.8
 
 2009-04-04 Didrik Pinte <dpinte at dipole-consulting.com>

Modified: trunk/thuban/Thuban/Lib/fileutil.py
===================================================================
--- trunk/thuban/Thuban/Lib/fileutil.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/Thuban/Lib/fileutil.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -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":

Modified: trunk/thuban/Thuban/Model/resource.py
===================================================================
--- trunk/thuban/Thuban/Model/resource.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/Thuban/Model/resource.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -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"
 

Modified: trunk/thuban/Thuban/UI/__init__.py
===================================================================
--- trunk/thuban/Thuban/UI/__init__.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/Thuban/UI/__init__.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -80,7 +80,7 @@
         Thuban.set_internal_encoding(encoding)
 
 
-install_wx_translation()
+#install_wx_translation()
 
 # We define a function that will return the internal representation
 # for a value returned from wxString.

Modified: trunk/thuban/Thuban/UI/application.py
===================================================================
--- trunk/thuban/Thuban/UI/application.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/Thuban/UI/application.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -32,6 +32,8 @@
 from Thuban.Model.layer import RasterLayer
 import Thuban.Model.resource
 
+from Thuban.UI import install_wx_translation
+
 from extensionregistry import ext_registry
 
 import view
@@ -53,10 +55,13 @@
     class derived from wxApp. In Thuban the application class holds
     references to the main window and the session.
     """
-
-    def OnInit(self):
+    
+    def OnInit(self):    
+        
         sys.excepthook = self.ShowExceptionDialog
 
+        install_wx_translation()
+        
         # Initialize instance variables before trying to create any
         # windows.  Creating windows can start an event loop if
         # e.g. message boxes are popped up for some reason, and event
@@ -105,6 +110,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 +152,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)

Modified: trunk/thuban/Thuban/__init__.py
===================================================================
--- trunk/thuban/Thuban/__init__.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/Thuban/__init__.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -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

Modified: trunk/thuban/setup.py
===================================================================
--- trunk/thuban/setup.py	2009-05-18 13:50:16 UTC (rev 2874)
+++ trunk/thuban/setup.py	2009-05-18 14:12:22 UTC (rev 2875)
@@ -155,10 +155,10 @@
                    
     wx_cs_params[CS_INCDIRS] = wx_inc
     wx_cs_params[CS_LIBDIRS] = wx_lib
-    wx_cs_params[CS_LIBS] = ['wxmsw28uh_core' , 'wxmsw28uh_stc', 'wxbase28uh' ,\
-                             'wxmsw28uh_html' , 'wxmsw28uh_richtext' , 'wxmsw28uh_adv' , \
-                             'wxmsw28uh_xrc' , 'wxmsw28uh_aui', 'wxmsw28uh_gl' , 'wxmsw28uh_gizmos' , \
-                             'wxbase28uh_net' , 'wxbase28uh_xml']                    
+    wx_cs_params[CS_LIBS] = ['wxmsw28uh_core' ]#'wxmsw28uh_core' , 'wxmsw28uh_stc', 'wxbase28uh' ,\
+                             #'wxmsw28uh_html' , 'wxmsw28uh_richtext' , 'wxmsw28uh_adv' , \
+                             #'wxmsw28uh_xrc' , 'wxmsw28uh_aui', 'wxmsw28uh_gl' , 'wxmsw28uh_gizmos' , \
+                             #'wxbase28uh_net' , 'wxbase28uh_xml']                    
 
     gdal_config_script = ""
     gdal_cs_params = [[] for i in range(CS_NUM_PARAMS)]



More information about the Thuban-commits mailing list