[GRASS-SVN] r42950 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 29 15:25:06 EDT 2010
Author: martinl
Date: 2010-07-29 19:25:06 +0000 (Thu, 29 Jul 2010)
New Revision: 42950
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
grass/trunk/gui/wxpython/gui_modules/layertree.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/profile.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: clean up gcmd.<error message> classes
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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):
@@ -356,7 +293,7 @@
@param stdin standard input stream
@param verbose verbose level [0, 3] (--q, --v)
@param wait wait for child execution terminated
- @param rerr error handling (when CmdError raised).
+ @param rerr error handling (when GException raised).
True for redirection to stderr, False for GUI dialog,
None for no operation (quiet mode)
@param stdout redirect standard output or None
@@ -404,14 +341,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 +568,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/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -1352,8 +1352,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/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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)
@@ -1446,10 +1441,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))
@@ -1508,8 +1503,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:
@@ -2397,15 +2392,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)
@@ -3618,8 +3613,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/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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:
@@ -1314,8 +1314,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/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -1101,8 +1101,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/trunk/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -408,15 +408,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/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -414,8 +414,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':
@@ -426,8 +427,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()
@@ -463,8 +465,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()
@@ -1046,8 +1049,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/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -115,7 +115,7 @@
pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
view = ViewPositionWindow(panel, size = (175, 175),
mapwindow = self.mapWindow)
- self.win['view']['pos'] = view.GetId()
+ self.win['view']['position'] = view.GetId()
posSizer.Add(item = view,
pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("S")),
@@ -1136,7 +1136,7 @@
pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
pos = LightPositionWindow(panel, id = wx.ID_ANY, size = (175, 175),
mapwindow = self.mapWindow)
- self.win['light']['pos'] = pos.GetId()
+ self.win['light']['position'] = pos.GetId()
posSizer.Add(item = pos,
pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("S")),
@@ -1406,9 +1406,9 @@
self.FindWindowById(win).SetValue(value)
- viewWin = self.FindWindowById(self.win['view']['pos'])
- x, y = viewWin.UpdatePos(self.mapWindow.view['pos']['x'],
- self.mapWindow.view['pos']['y'])
+ viewWin = self.FindWindowById(self.win['view']['position'])
+ x, y = viewWin.UpdatePos(self.mapWindow.view['position']['x'],
+ self.mapWindow.view['position']['y'])
viewWin.Draw(pos = (x, y), scale = True)
viewWin.Refresh(False)
@@ -1432,7 +1432,7 @@
return
val = event.GetInt()
- self.mapWindow.light['pos']['z'] = val / 100.
+ self.mapWindow.light['position']['z'] = val / 100.
for win in self.win['light'][winName].itervalues():
self.FindWindowById(win).SetValue(val)
@@ -1556,32 +1556,32 @@
"""!Look at (view page)"""
sel = event.GetSelection()
if sel == 0: # top
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 1: # north
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 2: # south
- self.mapWindow.view['pos']['x'] = 0.5
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 1.0
elif sel == 3: # east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 4: # west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 0.5
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 0.5
elif sel == 5: # north-west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 6: # north-east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 0.0
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 0.0
elif sel == 7: # south-east
- self.mapWindow.view['pos']['x'] = 1.0
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 1.0
+ self.mapWindow.view['position']['y'] = 1.0
elif sel == 8: # south-west
- self.mapWindow.view['pos']['x'] = 0.0
- self.mapWindow.view['pos']['y'] = 1.0
+ self.mapWindow.view['position']['x'] = 0.0
+ self.mapWindow.view['position']['y'] = 1.0
self.PostViewEvent(zExag = True)
@@ -2426,7 +2426,7 @@
elif pageId == 'volume':
self.UpdateVectorPage(layer, data['vector'])
elif pageId == 'light':
- zval = self.mapWindow.light['pos']['z']
+ zval = self.mapWindow.light['position']['z']
bval = self.mapWindow.light['bright']
aval = self.mapWindow.light['ambient']
for control in ('spin', 'slider'):
@@ -2784,8 +2784,8 @@
elif ycoord > 1.0:
ycoord = 1.0
- self.data['pos']['x'] = xcoord
- self.data['pos']['y'] = ycoord
+ self.data['position']['x'] = xcoord
+ self.data['position']['y'] = ycoord
return xcoord, ycoord
@@ -2802,8 +2802,8 @@
event.Skip()
def PostDraw(self):
- x, y = self.UpdatePos(self.data['pos']['x'],
- self.data['pos']['y'])
+ x, y = self.UpdatePos(self.data['position']['x'],
+ self.data['position']['y'])
self.Draw(pos = (x, y), scale = True)
class ViewPositionWindow(PositionWindow):
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -589,8 +589,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)
@@ -764,11 +764,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()
@@ -835,8 +835,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)
@@ -869,7 +867,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/trunk/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/profile.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/profile.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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
@@ -174,7 +175,7 @@
self.mapfile = None
self.maskfile = None
- except gcmd.CmdError, e:
+ except gcmd.GException, e:
print >> sys.stderr, e
# clean up after problems
try:
@@ -260,7 +261,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
@@ -612,18 +613,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():
@@ -952,7 +952,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
@@ -1034,8 +1034,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
@@ -1143,8 +1143,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]
@@ -1182,8 +1182,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/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -1310,14 +1310,14 @@
# open vector map
try:
if not self.parent.MapWindow.CheckPseudoDC():
- raise gcmd.DigitError(parent=self.parent,
- message=_("Unable to initialize display driver of vector "
- "digitizer. See 'Command output' for details."))
+ raise gcmd.GException(_("Unable to initialize display driver of vector "
+ "digitizer. See 'Command output' for details."))
self.parent.digit.SetMapName(mapLayer.GetName())
- except gcmd.DigitError, e:
+ except gcmd.GException, e:
self.mapLayer = None
self.StopEditing()
- print >> sys.stderr, e # wxMessageBox
+ GError(parent = self.parent,
+ message = e)
return False
# update toolbar
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -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/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -36,7 +36,6 @@
import globalvar
from preferences import globalSettings as UserSettings
-#sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
try:
import wxnviz
except ImportError:
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2010-07-29 16:21:45 UTC (rev 42949)
+++ grass/trunk/gui/wxpython/wxgui.py 2010-07-29 19:25:06 UTC (rev 42950)
@@ -191,7 +191,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):
@@ -625,11 +626,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