[QGIS Commit] r15051 - in trunk/qgis/python/plugins/GdalTools: . tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 15 07:49:35 EST 2011


Author: brushtyler
Date: 2011-01-15 04:49:35 -0800 (Sat, 15 Jan 2011)
New Revision: 15051

Modified:
   trunk/qgis/python/plugins/GdalTools/GdalTools.py
   trunk/qgis/python/plugins/GdalTools/tools/GdalTools_utils.py
   trunk/qgis/python/plugins/GdalTools/tools/doGrid.py
   trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py
Log:
allowing unicode error messages


Modified: trunk/qgis/python/plugins/GdalTools/GdalTools.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/GdalTools.py	2011-01-14 23:24:26 UTC (rev 15050)
+++ trunk/qgis/python/plugins/GdalTools/GdalTools.py	2011-01-15 12:49:35 UTC (rev 15051)
@@ -32,7 +32,7 @@
   from osgeo import gdal
   from osgeo import ogr
 except ImportError, e:
-  error_str = str(e)
+  error_str = e.args[0]
   error_mod = error_str.replace( "No module named ", "" )
   if req_mods.has_key( error_mod ):
     error_str = error_str.replace( error_mod, req_mods[error_mod] )

Modified: trunk/qgis/python/plugins/GdalTools/tools/GdalTools_utils.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/GdalTools_utils.py	2011-01-14 23:24:26 UTC (rev 15050)
+++ trunk/qgis/python/plugins/GdalTools/tools/GdalTools_utils.py	2011-01-15 12:49:35 UTC (rev 15051)
@@ -181,10 +181,15 @@
 
   return shortName
 
+class UnsupportedOGRFormat(Exception):
+    def __init__(self): 
+      msg = QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" )
+      Exception.__init__(self, msg) 
+
 def getVectorFields(vectorFile):
     hds = ogr.Open( unicode(vectorFile).encode('utf8') )
     if hds == None:
-      raise Exception( QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" ) )
+      raise UnsupportedOGRFormat()
 
     fields = []
     names = []

Modified: trunk/qgis/python/plugins/GdalTools/tools/doGrid.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doGrid.py	2011-01-14 23:24:26 UTC (rev 15050)
+++ trunk/qgis/python/plugins/GdalTools/tools/doGrid.py	2011-01-15 12:49:35 UTC (rev 15051)
@@ -183,8 +183,8 @@
 
       try:
         (fields, names) = Utils.getVectorFields(vectorFile)
-      except Exception, e:
-        QErrorMessage(self).showMessage( str(e) )
+      except Utils.UnsupportedOGRFormat, e:
+        QErrorMessage(self).showMessage( e.args[0] )
 
         self.inputLayerCombo.clearEditText()
         self.inputLayerCombo.setCurrentIndex(-1)

Modified: trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py	2011-01-14 23:24:26 UTC (rev 15050)
+++ trunk/qgis/python/plugins/GdalTools/tools/doRasterize.py	2011-01-15 12:49:35 UTC (rev 15051)
@@ -104,8 +104,8 @@
 
       try:
         (fields, names) = Utils.getVectorFields(vectorFile)
-      except Exception, e:
-        QErrorMessage(self).showMessage( str(e) )
+      except Utils.UnsupportedOGRFormat, e:
+        QErrorMessage(self).showMessage( e.args[0] )
 
         self.inputLayerCombo.clearEditText()
         self.inputLayerCombo.setCurrentIndex(-1)



More information about the QGIS-commit mailing list