[GRASS-SVN] r47152 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 18 04:05:37 EDT 2011
Author: martinl
Date: 2011-07-18 01:05:37 -0700 (Mon, 18 Jul 2011)
New Revision: 47152
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: don't crash on v.db.connect
(merge r47150 from devbr6)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py 2011-07-18 08:04:27 UTC (rev 47151)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py 2011-07-18 08:05:37 UTC (rev 47152)
@@ -619,10 +619,7 @@
else:
GError(parent = parent,
message = stderr)
-
- if ret != 0:
- return None
-
+
Debug.msg(3, "gcmd.RunCommand(): print read error")
if not read:
if not getErrorMsg:
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2011-07-18 08:04:27 UTC (rev 47151)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2011-07-18 08:05:37 UTC (rev 47152)
@@ -626,16 +626,16 @@
class LayerSelect(wx.ComboBox):
"""!Creates combo box for selecting data layers defined for vector.
- The 'layer' terminology is likely to change for GRASS 7
"""
def __init__(self, parent,
- id=wx.ID_ANY, pos=wx.DefaultPosition,
- size=globalvar.DIALOG_LAYER_SIZE,
- vector=None, choices=[], initial=[], default=None):
-
+ id = wx.ID_ANY, pos = wx.DefaultPosition,
+ size = globalvar.DIALOG_LAYER_SIZE,
+ vector = None, choices = [], initial = [], default = None):
+
super(LayerSelect, self).__init__(parent, id, pos=pos, size=size,
choices=choices)
-
+
+ self.parent = parent
self.initial = initial
self.SetName("LayerSelect")
@@ -646,25 +646,39 @@
self.InsertLayers(vector = vector)
def InsertLayers(self, vector):
- """!Insert layers for a vector into the layer combobox"""
+ """!Insert layers for a vector into the layer combobox
+
+ @param vector name of vector map
+ """
if vector:
- layers = utils.GetVectorNumberOfLayers(self, vector)
+ layers = utils.GetVectorNumberOfLayers(vector)
else:
layers = list()
-
+
for layer in self.initial:
if layer in layers:
continue
layers.append(layer)
-
+
if self.default:
if len(layers) == 0:
layers.insert(0, str(self.default))
elif self.default not in layers:
layers.append(self.default)
-
+
if len(layers) >= 1:
self.SetItems(layers)
+
+ def Reset(self):
+ """!Reset value"""
+ items = self.GetItems()
+ if items:
+ if '-1' in items:
+ self.SetStringSelection('-1')
+ else:
+ self.SetSelection(0)
+ else:
+ self.SetValue('')
class DriverSelect(wx.ComboBox):
"""!Creates combo box for selecting database driver.
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2011-07-18 08:04:27 UTC (rev 47151)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2011-07-18 08:05:37 UTC (rev 47152)
@@ -220,6 +220,7 @@
if name == 'LayerSelect':
if map in cparams and not cparams[map]['layers']:
win.InsertLayers(vector = map)
+ win.Reset()
cparams[map]['layers'] = win.GetItems()
elif name == 'TableSelect':
@@ -1149,16 +1150,16 @@
if lyrvalue not in initial:
initial.append(str(lyrvalue))
- win = gselect.LayerSelect(parent=which_panel,
- initial=initial,
- default=p['default'])
+ win = gselect.LayerSelect(parent = which_panel,
+ initial = initial,
+ default = p['default'])
p['wxGetValue'] = win.GetStringSelection
win.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
win.Bind(wx.EVT_TEXT, self.OnSetValue)
win.SetValue(str(value)) # default or previously set value
else:
- win = wx.SpinCtrl(parent=which_panel, id=wx.ID_ANY,
- min=1, max=100, initial=int(p['default']))
+ win = wx.SpinCtrl(parent = which_panel, id = wx.ID_ANY,
+ min = 1, max = 100, initial = int(p['default']))
win.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
win.SetValue(int(value)) # default or previously set value
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2011-07-18 08:04:27 UTC (rev 47151)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2011-07-18 08:05:37 UTC (rev 47152)
@@ -272,8 +272,12 @@
"""!Sort list items (not case-sensitive)"""
list.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
-def GetVectorNumberOfLayers(parent, vector):
- """!Get list of vector layers"""
+def GetVectorNumberOfLayers(vector, parent = None):
+ """!Get list of vector layers
+
+ @param vector name of vector map
+ @param parent parent window (to show dialog) or None
+ """
layers = []
if not vector:
return layers
@@ -283,19 +287,19 @@
Debug.msg(5, "utils.GetVectorNumberOfLayers(): vector map '%s' not found" % vector)
return layers
- ret = gcmd.RunCommand('v.db.connect',
- parent = parent,
- flags = 'g',
- read = True,
- map = fullname,
- fs = ';')
-
- if not ret:
+ ret, out, msg = gcmd.RunCommand('v.db.connect',
+ getErrorMsg = True,
+ read = True,
+ flags = 'g',
+ map = fullname,
+ fs = ';')
+ if ret != 0:
+ sys.stderr.write(_("Vector map <%s>") % fullname + ": " + msg + "\n")
return layers
- else:
- Debug.msg(1, "GetVectorNumberOfLayers(): ret %s" % ret)
- for line in ret.splitlines():
+ Debug.msg(1, "GetVectorNumberOfLayers(): ret %s" % ret)
+
+ for line in out.splitlines():
try:
layer = line.split(';')[0]
if '/' in layer:
More information about the grass-commit
mailing list