Skip to content

Commit

Permalink
allowing unicode error messages
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15051 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Jan 15, 2011
1 parent 185ec5d commit 8133a99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/GdalTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] )
Expand Down
7 changes: 6 additions & 1 deletion python/plugins/GdalTools/tools/GdalTools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,15 @@ def fillVectorOutputFormat(aFilter = None, filename = None):

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 = []
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/GdalTools/tools/doGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def loadFields(self, vectorFile = QString()):

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)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/GdalTools/tools/doRasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def loadFields(self, vectorFile):

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)
Expand Down

0 comments on commit 8133a99

Please sign in to comment.