[GRASS-SVN] r42394 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 30 07:45:00 EDT 2010
Author: martinl
Date: 2010-05-30 07:44:59 -0400 (Sun, 30 May 2010)
New Revision: 42394
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/d.vect: avoid repetitive running of the same commands
(merge r42393 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 2010-05-30 11:36:45 UTC (rev 42393)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py 2010-05-30 11:44:59 UTC (rev 42394)
@@ -596,6 +596,9 @@
def RunCommand(prog, flags = "", overwrite = False, quiet = False, verbose = False,
parent = None, read = False, stdin = None, **kwargs):
"""Run GRASS command"""
+ Debug.msg(1, "gcmd.RunCommand(): %s" % ' '.join(grass.make_command(prog, flags, overwrite,
+ quiet, verbose, **kwargs)))
+
kwargs['stderr'] = subprocess.PIPE
if read:
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2010-05-30 11:36:45 UTC (rev 42393)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2010-05-30 11:44:59 UTC (rev 42394)
@@ -603,9 +603,14 @@
if vector:
self.InsertColumns(vector, layer)
- def InsertColumns(self, vector, layer):
- """Insert columns for a vector attribute table into the columns combobox"""
- dbInfo = VectorDBInfo(vector)
+ def InsertColumns(self, vector, layer, dbInfo = None):
+ """!Insert columns for a vector attribute table into the columns combobox
+
+ @param vector vector name
+ @param layer vector layer number
+ """
+ if not dbInfo:
+ dbInfo = VectorDBInfo(vector)
try:
table = dbInfo.layers[int(layer)]['table']
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2010-05-30 11:36:45 UTC (rev 42393)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2010-05-30 11:44:59 UTC (rev 42394)
@@ -211,6 +211,11 @@
map = pMap.get('value', '')
else:
map = None
+
+ # avoid running db.describe several times
+ cparams = dict()
+ cparams[map] = { 'dbInfo' : None,
+ 'layers' : None, }
# update reference widgets
for uid in p['wxId-bind']:
@@ -218,8 +223,10 @@
name = win.GetName()
if name == 'LayerSelect':
- self.data[win.InsertLayers] = { 'vector' : map }
-
+ if not cparams[map]['layers']:
+ win.InsertLayers(vector = map)
+ cparams[map]['layers'] = win.GetItems()
+
elif name == 'TableSelect':
pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)
driver = db = None
@@ -243,7 +250,10 @@
layer = 1
if map:
- self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer }
+ if not cparams[map]['dbInfo']:
+ cparams[map]['dbInfo'] = gselect.VectorDBInfo(map)
+ self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer,
+ 'dbInfo' : cparams[map]['dbInfo'] }
else: # table
driver = db = None
pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2010-05-30 11:36:45 UTC (rev 42393)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py 2010-05-30 11:44:59 UTC (rev 42394)
@@ -32,6 +32,7 @@
compatPath = os.path.join(globalvar.ETCWXDIR, "compat")
sys.path.append(compatPath)
import subprocess
+from debug import Debug
def GetTempfile(pref=None):
"""
@@ -251,17 +252,25 @@
if not vector:
return layers
- cmdlist = ['v.category', '-g',
- 'input=%s' % vector,
- 'option=report']
+ ret = gcmd.RunCommand('v.category',
+ flags = 'g',
+ read = True,
+ input = vector,
+ option = 'report')
- for line in gcmd.Command(cmdlist, rerr=None).ReadStdOutput():
- if 'all' in line:
- try:
- layers.append(line.split(' ')[0])
- except IndexError:
- pass
+ if not ret:
+ return layers
+ for line in ret.splitlines():
+ try:
+ layer = line.split(' ')[0]
+ if layer not in layers:
+ layers.append(layer)
+ except ValueError:
+ pass
+ Debug.msg(3, "utils.GetVectorNumberOfLayers(): vector=%s -> %s" % \
+ (vector, ','.join(layers)))
+
return layers
def Deg2DMS(lon, lat):
More information about the grass-commit
mailing list