[GRASS-SVN] r42391 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 30 07:19:16 EDT 2010
Author: martinl
Date: 2010-05-30 07:19:16 -0400 (Sun, 30 May 2010)
New Revision: 42391
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: minor fixes, don't render empty image
(merge r42390 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-05-30 11:15:23 UTC (rev 42390)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-05-30 11:19:16 UTC (rev 42391)
@@ -37,13 +37,13 @@
import globalvar
-grassPath = os.path.join(globalvar.ETCDIR, "python")
-sys.path.append(grassPath)
+sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
import grass.script as grass
import gcmd
import utils
from preferences import globalSettings as UserSettings
+from debug import Debug
wxGdalSelect, EVT_GDALSELECT = NewEvent()
@@ -96,9 +96,9 @@
self.ftype = ftype
# remove vector maps which do not contain given feature type
- self.tcp.SetFilter(self.__isElement)
+ self.tcp.SetFilter(self._isElement)
- def __isElement(self, vectorName):
+ def _isElement(self, vectorName):
"""!Check if element should be filtered out"""
try:
if int(grass.vector_info_topo(vectorName)[self.ftype]) < 1:
@@ -410,12 +410,12 @@
# dictionary of table and associated columns (type, length, values, ids)
self.tables = {}
- if not self.__CheckDBConnection(): # -> self.layers
+ if not self._CheckDBConnection(): # -> self.layers
return
- self.__DescribeTables() # -> self.tables
+ self._DescribeTables() # -> self.tables
- def __CheckDBConnection(self):
+ def _CheckDBConnection(self):
"""!Check DB connection"""
nuldev = file(os.devnull, 'w+')
self.layers = grass.vector_db(map=self.map, stderr=nuldev)
@@ -426,13 +426,16 @@
return True
- def __DescribeTables(self):
+ def _DescribeTables(self):
"""!Describe linked tables"""
for layer in self.layers.keys():
# determine column names and types
table = self.layers[layer]["table"]
columns = {} # {name: {type, length, [values], [ids]}}
i = 0
+ Debug.msg(1, "gselect.VectorDBInfo._DescribeTables(): table=%s driver=%s database=%s" % \
+ (self.layers[layer]["table"], self.layers[layer]["driver"],
+ self.layers[layer]["database"]))
for item in grass.db_describe(table = self.layers[layer]["table"],
driver = self.layers[layer]["driver"],
database = self.layers[layer]["database"])['cols']:
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2010-05-30 11:15:23 UTC (rev 42390)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2010-05-30 11:19:16 UTC (rev 42391)
@@ -909,25 +909,29 @@
else:
del os.environ["GRASS_REGION"]
- # run g.pngcomp to get composite image
- ret = gcmd.RunCommand('g.pnmcomp',
- input = '%s' % ",".join(maps),
- mask = '%s' % ",".join(masks),
- opacity = '%s' % ",".join(opacities),
- background = bgcolor,
- width = self.width,
- height = self.height,
- output = self.mapfile)
+ if maps:
+ # run g.pngcomp to get composite image
+ ret = gcmd.RunCommand('g.pnmcomp',
+ input = '%s' % ",".join(maps),
+ mask = '%s' % ",".join(masks),
+ opacity = '%s' % ",".join(opacities),
+ background = bgcolor,
+ width = self.width,
+ height = self.height,
+ output = self.mapfile)
+
+ if ret != 0:
+ print >> sys.stderr, _("ERROR: Rendering failed")
+ return None
+
+ Debug.msg (3, "Map.Render() force=%s file=%s" % (force, self.mapfile))
- if ret != 0:
- print >> sys.stderr, _("ERROR: Rendering failed")
- return None
-
# back to original gisrc
if self.gisrc:
os.environ["GISRC"] = gisrc_orig
- Debug.msg (3, "Map.Render() force=%s file=%s" % (force, self.mapfile))
+ if not maps:
+ return None
return self.mapfile
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2010-05-30 11:15:23 UTC (rev 42390)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2010-05-30 11:19:16 UTC (rev 42391)
@@ -20,22 +20,16 @@
import locale
import globalvar
-grassPath = os.path.join(globalvar.ETCDIR, "python")
-sys.path.append(grassPath)
+sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
from grass.script import core as grass
import gcmd
-try:
- import subprocess
-except:
- compatPath = os.path.join(globalvar.ETCWXDIR, "compat")
- sys.path.append(compatPath)
- import subprocess
+from debug import Debug
def normalize_whitespace(text):
"""!Remove redundant whitespace from a string"""
- return string.join( string.split(text), ' ')
+ return string.join(string.split(text), ' ')
def GetTempfile(pref=None):
"""
@@ -291,10 +285,13 @@
cmdlist = ['v.category',
'input=%s' % vector,
'option=report']
+ if not vector:
+ return layers
layers = []
ret = gcmd.RunCommand('v.category',
+ flags = 'g',
read = True,
input = vector,
option = 'report')
@@ -303,14 +300,14 @@
return layers
for line in ret.splitlines():
- if not 'Layer' in line:
- continue
-
- value = line.split(':')[1].strip()
- if '/' in value: # value/name
- layers.append(value.split('/')[0])
- else:
- layers.append(value)
+ 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
More information about the grass-commit
mailing list