mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
allowing unicode error messages
git-svn-id: http://svn.osgeo.org/qgis/trunk@15051 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
185ec5db69
commit
8133a995d1
@ -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] )
|
||||
|
@ -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 = []
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user