[GRASS-SVN] r42951 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 29 15:34:56 EDT 2010
Author: martinl
Date: 2010-07-29 19:34:56 +0000 (Thu, 29 Jul 2010)
New Revision: 42951
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/profile.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: clean up gcmd.<error message> classes
(merge r42950 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -93,8 +93,9 @@
try:
keyColumn = self.LoadData(layer)
- except gcmd.DBMError, e:
- e.Show()
+ except gcmd.GException, e:
+ GError(parent = self,
+ message = e)
return
#
@@ -150,10 +151,9 @@
try:
self.columns = self.mapDBInfo.tables[tableName]
except KeyError:
- raise gcmd.DBMError(message=_("Attribute table <%s> not found. "
- "For creating the table switch to "
- "'Manage layers' tab.") % tableName,
- parent=self.parent)
+ raise gcmd.GException(_("Attribute table <%s> not found. "
+ "For creating the table switch to "
+ "'Manage layers' tab.") % tableName)
if not columns:
columns = self.mapDBInfo.GetColumns(tableName)
@@ -303,13 +303,13 @@
cat = self.columns[columns[j]]['ctype'] (value)
except ValueError, e:
cat = -1
- gcmd.GMessage(parent = self,
- message=_("Error loading attribute data. "
- "Record number: %(rec)d. Unable to convert value '%(val)s' in "
- "key column (%(key)s) to integer.\n\n"
- "Details: %(detail)s") % \
- { 'rec' : i + 1, 'val' : value,
- 'key' : keyColumn, 'detail' : e})
+ gcmd.GError(parent = self,
+ message=_("Error loading attribute data. "
+ "Record number: %(rec)d. Unable to convert value '%(val)s' in "
+ "key column (%(key)s) to integer.\n\n"
+ "Details: %(detail)s") % \
+ { 'rec' : i + 1, 'val' : value,
+ 'key' : keyColumn, 'detail' : e})
j += 1
self.itemIndexMap.append(i)
@@ -1927,10 +1927,9 @@
keyColumn = listWin.LoadData(self.layer, where=whereCol + whereVal)
else:
keyColumn = listWin.LoadData(self.layer)
- except gcmd.CmdError, e:
- wx.MessageBox(parent=self,
- message=_("Loading attribute data failed.\n\n%s") % e.message,
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ except gcmd.GException, e:
+ gcmd.GError(parent = self,
+ message = _("Loading attribute data failed.\n\n%s") % e.value)
self.FindWindowById(self.layerPage[self.layer]['where']).SetValue('')
else:
# advanced sql statement
@@ -1952,10 +1951,9 @@
try:
keyColumn = listWin.LoadData(self.layer, columns=cols,
where=where, sql=sql)
- except gcmd.CmdError, e:
- wx.MessageBox(parent=self,
- message=_("Loading attribute data failed.\n\n%s") % e.message,
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ except gcmd.GException, e:
+ gcmd.GError(parent = self,
+ message = _("Loading attribute data failed.\n\n%s") % e.value)
win.SetValue("SELECT * FROM %s" % self.mapDBInfo.layers[self.layer]['table'])
# sort by key column
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -4,13 +4,10 @@
@brief wxGUI command interface
Classes:
+ - GError
+ - GWarning
+ - GMessage
- GException
- - GStdError
- - CmdError
- - SettingsError
- - DigitError
- - DBMError
- - NvizError
- Popen (from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554)
- Command
- CommandThread
@@ -60,117 +57,57 @@
import utils
from debug import Debug as Debug
-class GMessage:
- def __init__(self, parent, message, msgType = 'error'):
- if msgType == 'error':
- caption = _('Error')
- style = wx.OK | wx.ICON_ERROR | wx.CENTRE
- elif msgType == 'info':
- caption = _('Message')
- style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE
- elif msgType == 'warning':
- caption = _('Warning')
- style = wx.OK | wx.ICON_WARNING | wx.CENTRE
+class GError:
+ def __init__(self, message, parent = None):
+ caption = _('Error')
+ style = wx.OK | wx.ICON_ERROR | wx.CENTRE
- if msgType != 'error':
+ exc_type, exc_value, exc_traceback = sys.exc_info()
+ if exc_traceback:
+ exception = traceback.format_exc()
+ reason = exception.splitlines()[-2].split(':', 1)[-1].strip()
+
+ if Debug.get_level() > 0 and exc_traceback:
+ sys.stderr.write(exception)
+
+ if exc_traceback:
wx.MessageBox(parent = parent,
- message = message,
+ message = message + '\n\n%s: %s\n\n%s' % \
+ (_('Reason'),
+ reason, exception),
caption = caption,
style = style)
else:
- exc_type, exc_value, exc_traceback = sys.exc_info()
- if exc_traceback:
- exception = traceback.format_exc()
- reason = exception.splitlines()[-2].split(':', 1)[-1].strip()
-
- if Debug.get_level() > 0 and exc_traceback:
- sys.stderr.write(exception)
-
- if exc_traceback:
- wx.MessageBox(parent = parent,
- message = message + '\n\n%s: %s\n\n%s' % \
- (_('Reason'),
- reason, exception),
- caption = caption,
- style = style)
- else:
- wx.MessageBox(parent = parent,
- message = message,
- caption = caption,
- style = style)
-
-class GError(Exception):
+ wx.MessageBox(parent = parent,
+ message = message,
+ caption = caption,
+ style = style)
+
+class GWarning:
+ def __init__(self, message, parent = None):
+ caption = _('Warning')
+ style = wx.OK | wx.ICON_WARNING | wx.CENTRE
+ wx.MessageBox(parent = parent,
+ message = message,
+ caption = caption,
+ style = style)
+
+class GMessage:
+ def __init__(self, message, parent = None):
+ caption = _('Message')
+ style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE
+ wx.MessageBox(parent = parent,
+ message = message,
+ caption = caption,
+ style = style)
+
+class GException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return str(self.value)
-class GException(Exception):
- """!Generic exception"""
- def __init__(self, message, title = _("Error"), parent = None):
- self.msg = message
- self.parent = parent
- self.title = title
-
- def Show(self):
- GMessage(parent = self.parent,
- message = self.msg,
- msgType = 'error')
-
- def GetMessage(self):
- return self.msg
-
- def __str__(self):
- self.Show()
-
- return ''
-
-class GStdError(GException):
- """!Generic exception"""
-
- def __init__(self, message, title = _("Error"), parent = None):
- GException.__init__(self, message, title=title, parent=parent)
-
-class CmdError(GException):
- """!Exception used for GRASS commands.
-
- See Command class (command exits with EXIT_FAILURE,
- G_fatal_error() is called)."""
- def __init__(self, cmd, message, parent=None):
- GException.__init__(self, message,
- title=_("Error in command execution '%s'" % cmd),
- parent=parent)
-
-class SettingsError(GException):
- """!Exception used for GRASS settings, see
- gui_modules/preferences.py."""
- def __init__(self, message, parent=None):
- GException.__init__(self, message,
- title=_("Preferences error"),
- parent=parent)
-
-class DigitError(GException):
- """!Exception raised during digitization session"""
- def __init__(self, message, parent=None):
- GException.__init__(self, message,
- title=_("Vector digitizer error"),
- parent=parent)
-
-class DBMError(GException):
- """!Attribute Table Manager exception class"""
- def __init__(self, message, parent=None):
- GException.__init__(self, message,
- title=_("Attribute table manager error"),
- parent=parent)
-
-class NvizError(GException):
- """!Nviz exception class"""
- def __init__(self, message, parent=None):
- GException.__init__(self, message,
- title=_("Nviz error"),
- parent=parent)
-
class Popen(subprocess.Popen):
"""!Subclass subprocess.Popen"""
def __init__(self, *args, **kwargs):
@@ -361,7 +298,6 @@
def __init__ (self, cmd, stdin=None,
verbose=None, wait=True, rerr=False,
stdout=None, stderr=None):
-
Debug.msg(1, "gcmd.Command(): %s" % ' '.join(cmd))
self.cmd = cmd
self.stderr = stderr
@@ -404,14 +340,13 @@
(' '.join(cmd), wait, self.returncode, self.cmdThread.isAlive()))
if rerr is not None and self.returncode != 0:
if rerr is False: # GUI dialog
- raise CmdError(cmd=self.cmd,
- message="%s '%s'%s%s%s %s%s" %
- (_("Execution failed:"),
- ' '.join(self.cmd),
- os.linesep, os.linesep,
- _("Details:"),
- os.linesep,
- _("Error: ") + self.__GetError()))
+ raise GException("%s '%s'%s%s%s %s%s" % \
+ (_("Execution failed:"),
+ ' '.join(self.cmd),
+ os.linesep, os.linesep,
+ _("Details:"),
+ os.linesep,
+ _("Error: ") + self.__GetError()))
elif rerr == sys.stderr: # redirect message to sys
stderr.write("Execution failed: '%s'" % (' '.join(self.cmd)))
stderr.write("%sDetails:%s%s" % (os.linesep,
@@ -632,12 +567,10 @@
ret = ps.returncode
- if ret != 0 and parent:
- e = CmdError(cmd = prog,
- message = stderr,
- parent = parent)
- e.Show()
-
+ if ret != 0 and parent:
+ GError(parent = parent,
+ message = stderr)
+
if not read:
if not getErrorMsg:
return ret
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -287,10 +287,11 @@
gcmd.RunCommand(prog = cmd[0],
overwrite = overwrite,
**cmd[1])
- except gcmd.CmdError, e:
- e.Show()
+ except gcmd.GException, e:
+ gcmd.GError(parent = self,
+ message = e)
return None
-
+
#
# create attribute table
#
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -71,7 +71,7 @@
import goutput
import gselect
from debug import Debug
-from gcmd import GMessage, GError
+from gcmd import GMessage, GException, GWarning, GError
from gdialogs import ElementDialog, GetImageHandlers
from preferences import PreferencesBaseDialog, globalSettings as UserSettings
from ghelp import SearchModuleWindow
@@ -227,7 +227,7 @@
try:
gxmXml = ProcessModelFile(etree.parse(filename))
except StandardError, e:
- raise GError(e)
+ raise GException(e)
if self.canvas:
win = self.canvas.parent
@@ -689,8 +689,7 @@
if not rast and not vect and not rast3d:
GMessage(parent = self,
- message = _('Nothing to delete.'),
- msgType = 'info')
+ message = _('Nothing to delete.'))
return
dlg = wx.MessageDialog(parent = self,
@@ -863,8 +862,7 @@
"""!Run entire model"""
if self.model.GetNumItems() < 1:
GMessage(parent = self,
- message = _('Model is empty. Nothing to run.'),
- msgType = 'info')
+ message = _('Model is empty. Nothing to run.'))
return
# validation
@@ -894,8 +892,8 @@
err = dlg.GetErrors()
if err:
- GMessage(parent = self,
- message = unicode('\n'.join(err)))
+ GError(parent = self,
+ message = unicode('\n'.join(err)))
return
self.goutput.cmdThread.SetId(-1)
@@ -950,20 +948,17 @@
"""!Validate entire model"""
if self.model.GetNumItems() < 1:
GMessage(parent = self,
- message = _('Model is empty. Nothing to validate.'),
- msgType = 'info')
+ message = _('Model is empty. Nothing to validate.'))
return
errList = self._validateModel()
if errList:
- GMessage(parent = self,
- message = _('Model is not valid.\n\n%s') % '\n'.join(errList),
- msgType = 'warning')
+ GWarning(parent = self,
+ message = _('Model is not valid.\n\n%s') % '\n'.join(errList))
else:
GMessage(parent = self,
- message = _('Model is valid.'),
- msgType = 'info')
+ message = _('Model is valid.'))
def OnExportImage(self, event):
"""!Export model to image (default image)
@@ -1452,10 +1447,10 @@
"""
try:
self.model.LoadModel(filename)
- except GError, e:
- GMessage(parent = self,
- message = _("Reading model file <%s> failed.\n"
- "Invalid file, unable to parse XML document.") % filename)
+ except GException, e:
+ GError(parent = self,
+ message = _("Reading model file <%s> failed.\n"
+ "Invalid file, unable to parse XML document.") % filename)
self.modelFile = filename
self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile))
@@ -1514,8 +1509,8 @@
try:
WriteModelFile(fd = tmpfile, model = self.model)
except StandardError:
- GMessage(parent = self,
- message = _("Writing current settings to model file failed."))
+ GError(parent = self,
+ message = _("Writing current settings to model file failed."))
return False
try:
@@ -2403,15 +2398,15 @@
cmd = self.GetCmd()
if len(cmd) < 1:
- GMessage(parent = self,
- message = _("Command not defined.\n\n"
- "Unable to add new action to the model."))
+ GError(parent = self,
+ message = _("Command not defined.\n\n"
+ "Unable to add new action to the model."))
return
if cmd[0] not in globalvar.grassCmd['all']:
- GMessage(parent = self,
- message = _("'%s' is not a GRASS module.\n\n"
- "Unable to add new action to the model.") % cmd[0])
+ GError(parent = self,
+ message = _("'%s' is not a GRASS module.\n\n"
+ "Unable to add new action to the model.") % cmd[0])
return
self.EndModal(wx.ID_OK)
@@ -3624,8 +3619,8 @@
self.name.SetFocus()
if msg:
- GMessage(parent = self,
- message = msg)
+ GError(parent = self,
+ message = msg)
else:
self.type.SetSelection(0)
self.value.SetValue('')
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -47,7 +47,7 @@
from icon import Icons as Icons
from preferences import globalSettings as UserSettings
from vdigit import haveVDigit
-from gcmd import GMessage
+from gcmd import GError
try:
import subprocess
except:
@@ -1315,8 +1315,8 @@
mapname = utils.GetLayerNameFromCmd(dcmd, layerType=mapLayer.type,
fullyQualified=True)
if not mapname:
- GMessage(parent=self,
- message=_("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd))
+ GError(parent=self,
+ message=_("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd))
return
self.SetItemText(layer, mapname + ' (opacity: ' + str(opacity) + '%)')
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -1099,8 +1099,7 @@
img = self.MapWindow.img
if not img:
gcmd.GMessage(parent = self,
- message = _("Nothing to render (empty map). Operation canceled."),
- msgType = 'info')
+ message = _("Nothing to render (empty map). Operation canceled."))
return
filetype, ltype = gdialogs.GetImageHandlers(img)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mcalc_builder.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -393,15 +393,13 @@
"""
name = self.newmaptxt.GetValue().strip()
if not name:
- gcmd.GMessage(parent = self,
- message = _("You must enter the name of a new map to create"),
- msgType = 'info')
+ gcmd.GError(parent = self,
+ message = _("You must enter the name of a new map to create"))
return
if not self.text_mcalc.GetValue().strip():
- gcmd.GMessage(parent = self,
- message = _("You must enter a mapcalc statement to create a new map"),
- msgType = 'info')
+ gcmd.GError(parent = self,
+ message = _("You must enter a mapcalc statement to create a new map"))
return
mctxt = self.text_mcalc.GetValue().strip().replace("\n"," ")
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -413,8 +413,9 @@
self.LoadRaster(item)
elif type == '3d-raster':
self.LoadRaster3d(item)
- except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz:" + e.message
+ except gcmd.GException, e:
+ GError(parent = self,
+ message = e)
try:
if type == 'vector':
@@ -425,8 +426,9 @@
if data['vector'][v]:
vecType.append(v)
self.LoadVector(item, vecType)
- except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz:" + e.message
+ except gcmd.GException, e:
+ GError(parent = self,
+ message = e)
self.init = False
stop = time.time()
@@ -462,8 +464,9 @@
self.UnloadVector(layer, vecType)
self.UpdateView(None)
- except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz:" + e.message
+ except gcmd.GException, e:
+ gcmd.GError(parent = self,
+ message = e)
self.lmgr.nviz.UpdateSettings()
@@ -1045,8 +1048,7 @@
error = _("Unable to set data layer properties (id = %d)") % id
if error:
- raise gcmd.NvizError(parent = self.parent,
- message = _("Setting data layer properties failed.\n\n%s") % error)
+ raise gcmd.GException(_("Setting data layer properties failed.\n\n%s") % error)
for prop in ('size', 'width', 'marker', 'color'):
if data[prop].has_key('update'):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -583,8 +583,8 @@
self.userSettings = copy.deepcopy(self.defaultSettings)
try:
self.ReadSettingsFile()
- except gcmd.SettingsError, e:
- print >> sys.stderr, e.message
+ except gcmd.GException, e:
+ print >> sys.stderr, e.value
#
# internal settings (based on user settings)
@@ -766,11 +766,11 @@
file.write('%s' % self.sep)
file.write(os.linesep)
except IOError, e:
- raise gcmd.SettingsError(message=e)
+ raise gcmd.GException(e)
except StandardError, e:
- raise gcmd.SettingsError(message=_('Writing settings to file <%(file)s> failed.'
- '\n\nDetails: %(detail)s') % { 'file' : filePath,
- 'detail' : e })
+ raise gcmd.GException(_('Writing settings to file <%(file)s> failed.'
+ '\n\nDetails: %(detail)s') % { 'file' : filePath,
+ 'detail' : e })
file.close()
@@ -837,8 +837,6 @@
return settings[group][key][subkey]
except KeyError:
- #raise gcmd.SettingsError("%s %s:%s:%s." % (_("Unable to get value"),
- # group, key, subkey))
print >> sys.stderr, "Settings: unable to get value '%s:%s:%s'\n" % \
(group, key, subkey)
@@ -871,7 +869,7 @@
else:
settings[group][key][subkey] = value
except KeyError:
- raise gcmd.SettingsError("%s '%s:%s:%s'" % (_("Unable to set "), group, key, subkey))
+ raise gcmd.GException("%s '%s:%s:%s'" % (_("Unable to set "), group, key, subkey))
def Append(self, dict, group, key, subkey, value):
"""!Set value of key/subkey
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/profile.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/profile.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -437,8 +437,9 @@
datalist.append((dist,elev))
return datalist
- except gcmd.CmdError, e:
- print e
+ except gcmd.GException, e:
+ gcmd.GError(parent = self,
+ message = e)
return None
def OnCreateProfile(self, event):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -41,6 +41,7 @@
import globalvar
import utils
import gcmd
+from gcmd import GException
from debug import Debug as Debug
from preferences import globalSettings as UserSettings
@@ -131,8 +132,8 @@
'overlay')
if self.type not in layertypes:
- raise gcmd.GStdError(_("<%(name)s>: layer type <%(type)s> is not supported yet.") % \
- {'type' : self.type, 'name' : self.name})
+ raise gcmd.GException(_("<%(name)s>: layer type <%(type)s> is not supported yet.") % \
+ {'type' : self.type, 'name' : self.name})
#
# start monitor
@@ -188,7 +189,7 @@
self.mapfile = None
self.maskfile = None
- except gcmd.CmdError, e:
+ except gcmd.GException, e:
print >> sys.stderr, e
# clean up after problems
try:
@@ -278,7 +279,7 @@
'shaded', 'rgb', 'his', 'rastarrow', 'rastnum',
'thememap', 'themechart', 'grid', 'labels',
'geodesic','rhumb'):
- raise gcmd.GStdError(_("Unsupported map layer type '%s'") % str(type))
+ raise gcmd.GException(_("Unsupported map layer type '%s'") % str(type))
self.type = type
@@ -630,18 +631,17 @@
read = True,
**cmd)
if not ret:
- e = gcmd.CmdError(cmd = 'g.region', message = '')
if rast:
- e.message = _("Unable to zoom to raster map <%s>.") % rast[0] + \
- '%s%s' % (os.linesep, os.linesep) + e.message
+ message = _("Unable to zoom to raster map <%s>.") % rast[0] + \
+ '%s%s' % (os.linesep, os.linesep) + e.message
elif vect:
- e.message = _("Unable to zoom to vector map <%s>.") % vect[0] + \
- '%s%s' % (os.linesep, os.linesep) + e.message
+ message = _("Unable to zoom to vector map <%s>.") % vect[0] + \
+ '%s%s' % (os.linesep, os.linesep) + e.message
else:
- e.message = _("Unable to get current geographic extent. "
- "Force quiting wxGUI. Please run manually g.region to "
- "fix the problem.")
- e.Show()
+ message = _("Unable to get current geographic extent. "
+ "Force quiting wxGUI. Please run manually g.region to "
+ "fix the problem.")
+ GError(message)
return self.region
for reg in ret.splitlines():
@@ -968,7 +968,7 @@
Debug.msg (3, "Map.AddLayer(): layer=%s" % layer.name)
if l_render:
if not layer.Render():
- raise gcmd.GStdError(_("Unable to render map layer <%s>.") % (name))
+ raise gcmd.GException(_("Unable to render map layer <%s>.") % (name))
return layer
@@ -1050,8 +1050,8 @@
layer.SetOpacity(kargs['opacity'])
if render and not layer.Render():
- raise gcmd.GException(_("Unable to render map layer <%s>.") %
- (name))
+ raise GException(_("Unable to render map layer <%s>.") %
+ (name))
return layer
@@ -1159,8 +1159,8 @@
self.overlays.append(overlay)
if l_render and command != '' and not overlay.Render():
- raise gcmd.GException(_("Unable render overlay <%s>.") %
- (name))
+ raise GException(_("Unable render overlay <%s>.") %
+ (name))
return self.overlays[-1]
@@ -1198,8 +1198,8 @@
overlay.SetOpacity(kargs['opacity'])
if render and command != [] and not overlay.Render():
- raise gcmd.GException(_("Unable render overlay <%s>") %
- (name))
+ raise GException(_("Unable render overlay <%s>") %
+ (name))
return overlay
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -1157,12 +1157,16 @@
self.mapLayer = mapLayer
# open vector map
- if not self.parent.MapWindow.CheckPseudoDC():
- # gcmd.GMessage(parent = self.parent,
- # message = _("Unable to initialize display driver of vector "
- # "digitizer. See 'Command output' for details."))
+ try:
+ if not self.parent.MapWindow.CheckPseudoDC():
+ raise gcmd.GException(_("Unable to initialize display driver of vector "
+ "digitizer. See 'Command output' for details."))
+ self.parent.digit.SetMapName(mapLayer.GetName())
+ except gcmd.GException, e:
self.mapLayer = None
self.StopEditing()
+ GError(parent = self.parent,
+ message = e)
return False
self.parent.digit.SetMapName(mapLayer.GetName())
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -111,26 +111,23 @@
try:
ret = self.driver.Reset(self.map)
except StandardError, e:
- raise gcmd.DigitError(parent=self.mapWindow.parent,
- message="%s %s (%s)" % (_("Unable to initialize display driver of vector "
- "digitizer. See 'Command output' for details.\n\n"
- "Details:"), e, errorMsg))
+ raise gcmd.GException(_("Unable to initialize display driver of vector "
+ "digitizer. See 'Command output' for details.\n\n"
+ "Details: ") + e)
if map and ret == -1:
- raise gcmd.DigitError(parent=self.mapWindow.parent,
- message=_('Unable to open vector map <%s> for editing.\n\n'
- 'Data are probably corrupted, '
- 'try to run v.build to rebuild '
- 'the topology (Vector->Develop vector map->'
- 'Create/rebuild topology).') % map)
+ raise gcmd.GException(_('Unable to open vector map <%s> for editing.\n\n'
+ 'Data are probably corrupted, '
+ 'try to run v.build to rebuild '
+ 'the topology (Vector->Develop vector map->'
+ 'Create/rebuild topology).') % map)
if not map and ret != 0:
- raise gcmd.DigitError(parent=self.mapWindow.parent,
- message=_('Unable to open vector map <%s> for editing.\n\n'
- 'Data are probably corrupted, '
- 'try to run v.build to rebuild '
- 'the topology (Vector->Develop vector map->'
- 'Create/rebuild topology).') % map)
-
+ raise gcmd.GException(_('Unable to open vector map <%s> for editing.\n\n'
+ 'Data are probably corrupted, '
+ 'try to run v.build to rebuild '
+ 'the topology (Vector->Develop vector map->'
+ 'Create/rebuild topology).') % map)
+
if self.digit:
self.digit.InitCats()
@@ -684,7 +681,7 @@
ret = -2
if ret == -2:
- raise gcmd.DigitError, _("Undo failed, data corrupted.")
+ raise gcmd.GException(_("Undo failed, data corrupted."))
self.mapWindow.UpdateMap(render=False)
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-07-29 19:25:06 UTC (rev 42950)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-07-29 19:34:56 UTC (rev 42951)
@@ -188,7 +188,8 @@
self.workspaceChanged = False
# start with layer manager on top
- self.curr_page.maptree.mapdisplay.Raise()
+ if self.curr_page:
+ self.curr_page.maptree.mapdisplay.Raise()
wx.CallAfter(self.Raise)
def __createNoteBook(self):
@@ -616,12 +617,11 @@
# parse workspace file
try:
gxwXml = workspace.ProcessWorkspaceFile(etree.parse(filename))
- except Exception, err:
- raise gcmd.GStdError(_("Reading workspace file <%(file)s> failed.\n"
- "Invalid file, unable to parse XML document."
- "\n\n%(err)s") % \
- { 'file' : filename, 'err' : err },
- parent = self)
+ except Exception, e:
+ gcmd.GError(parent = self.parent,
+ message = _("Reading workspace file <%s> failed.\n"
+ "Invalid file, unable to parse XML document.") % filename)
+ return
busy = wx.BusyInfo(message=_("Please wait, loading workspace..."),
parent=self)
More information about the grass-commit
mailing list