[GRASS-SVN] r54496 - in grass/trunk/gui/wxpython: core iclass
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 2 07:37:56 PST 2013
Author: martinl
Date: 2013-01-02 07:37:53 -0800 (Wed, 02 Jan 2013)
New Revision: 54496
Modified:
grass/trunk/gui/wxpython/core/gcmd.py
grass/trunk/gui/wxpython/iclass/frame.py
grass/trunk/gui/wxpython/iclass/toolbars.py
Log:
wxGUI/iclass: better error handling when importing/exporting areas
Modified: grass/trunk/gui/wxpython/core/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/core/gcmd.py 2013-01-02 15:05:31 UTC (rev 54495)
+++ grass/trunk/gui/wxpython/core/gcmd.py 2013-01-02 15:37:53 UTC (rev 54496)
@@ -647,6 +647,10 @@
if stdin:
kwargs['stdin'] = subprocess.PIPE
+ if parent:
+ messageFormat = os.getenv('GRASS_MESSAGE_FORMAT', 'gui')
+ os.environ['GRASS_MESSAGE_FORMAT'] = 'standard'
+
Debug.msg(2, "gcmd.RunCommand(): command started")
start = time.time()
@@ -660,6 +664,9 @@
Debug.msg(3, "gcmd.RunCommand(): decoding string")
stdout, stderr = map(DecodeString, ps.communicate())
+ if parent: # restore previous settings
+ os.environ['GRASS_MESSAGE_FORMAT'] = messageFormat
+
ret = ps.returncode
Debug.msg(1, "gcmd.RunCommand(): get return code %d (%.6f sec)" % \
(ret, (time.time() - start)))
Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py 2013-01-02 15:05:31 UTC (rev 54495)
+++ grass/trunk/gui/wxpython/iclass/frame.py 2013-01-02 15:37:53 UTC (rev 54496)
@@ -511,6 +511,13 @@
"""
wx.BeginBusyCursor()
wx.Yield()
+
+ if 0 != RunCommand('g.copy',
+ vect = [vector, self.trainingAreaVector],
+ overwrite = True, quiet = True,
+ parent = self):
+ wx.EndBusyCursor()
+ return False
mapLayer = self.toolbars['vdigit'].mapLayer
# set mapLayer temporarily to None
@@ -522,14 +529,6 @@
wx.EndBusyCursor()
return False
- ret, msg = RunCommand('g.copy',
- vect = [vector, self.trainingAreaVector],
- overwrite = True,
- getErrorMsg = True)
- if ret != 0:
- wx.EndBusyCursor()
- return False
-
ret = self.toolbars['vdigit'].StartEditing(mapLayer)
if not ret:
wx.EndBusyCursor()
@@ -654,15 +653,18 @@
if '@' in vectorName:
vectorName = vectorName.split('@')[0]
- RunCommand('g.copy',
- vect = ','.join([self.trainingAreaVector, vectorName]),
- overwrite = True)
- # remove connection if exists:
+ if 0 != RunCommand('g.copy',
+ vect = [self.trainingAreaVector, vectorName],
+ overwrite = True, quiet = True, parent = self):
+ wx.EndBusyCursor()
+ return
+
+ # remove connection if exists
dbinfo = grass.vector_db(vectorName)
if dbinfo:
for layer in dbinfo.keys():
RunCommand('v.db.connect', flags = 'd', map = vectorName, layer = layer)
-
+
mapset = grass.gisenv()['MAPSET']
self.poMapInfo = displayDriver.OpenMap(name = self.trainingAreaVector, mapset = mapset)
@@ -670,7 +672,7 @@
wx.EndBusyCursor()
return
- # add table
+ # add new table
columns = ["class varchar(30)",
"color varchar(11)",
"n_cells integer",]
@@ -683,16 +685,13 @@
'stat' : statistic,
'format' : format})
- ret, msg = RunCommand('v.db.addtable',
- map = vectorName,
- columns = columns,
- getErrorMsg = True)
- if ret != 0:
+ if 0 != RunCommand('v.db.addtable',
+ map = vectorName,
+ columns = columns,
+ parent = self):
wx.EndBusyCursor()
- GMessage(parent = self, message = _("Failed to add attribute table. "
- "Details:\n%s" % msg))
return
-
+
# populate table
for cat in self.statisticsList:
stat = self.statisticsDict[cat]
@@ -709,7 +708,7 @@
self._runDBUpdate(map = vectorName, column = "band%d_min" % (i + 1), value = stat.bands[i].min, cat = cat)
self._runDBUpdate(map = vectorName, column = "band%d_mean" % (i + 1), value = stat.bands[i].mean, cat = cat)
self._runDBUpdate(map = vectorName, column = "band%d_max" % (i + 1), value = stat.bands[i].max, cat = cat)
-
+
wx.EndBusyCursor()
def _runDBUpdate(self, map, column, value, cat):
Modified: grass/trunk/gui/wxpython/iclass/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/toolbars.py 2013-01-02 15:05:31 UTC (rev 54495)
+++ grass/trunk/gui/wxpython/iclass/toolbars.py 2013-01-02 15:37:53 UTC (rev 54496)
@@ -41,9 +41,9 @@
'delCmd' : MetaIcon(img = 'layer-remove',
label = _('Delete selected map layer')),
'exportAreas' : MetaIcon(img = 'layer-export',
- label = _('Export training areas')),
+ label = _('Export training areas to vector map')),
'importAreas' : MetaIcon(img = 'layer-import',
- label = _('Import training areas')),
+ label = _('Import training areas from vector map')),
'addRgb' : MetaIcon(img = 'layer-rgb-add',
label = _('Add RGB map layer')),
}
More information about the grass-commit
mailing list