allowing unicode error messages

git-svn-id: http://svn.osgeo.org/qgis/trunk@15051 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
brushtyler 2011-01-15 12:49:35 +00:00
parent 185ec5db69
commit 8133a995d1
4 changed files with 11 additions and 6 deletions

View File

@ -32,7 +32,7 @@ try:
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] )

View File

@ -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 = []

View File

@ -183,8 +183,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
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)

View File

@ -104,8 +104,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
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)