[GRASS-SVN] r42390 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 30 07:15:25 EDT 2010
Author: martinl
Date: 2010-05-30 07:15:23 -0400 (Sun, 30 May 2010)
New Revision: 42390
Modified:
grass/trunk/gui/wxpython/gui_modules/gselect.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: minor fixes, don't render empty image
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2010-05-30 10:42:55 UTC (rev 42389)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2010-05-30 11:15:23 UTC (rev 42390)
@@ -38,13 +38,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()
@@ -97,9 +97,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:
@@ -411,12 +411,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)
@@ -427,13 +427,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/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2010-05-30 10:42:55 UTC (rev 42389)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2010-05-30 11:15:23 UTC (rev 42390)
@@ -893,25 +893,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/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py 2010-05-30 10:42:55 UTC (rev 42389)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py 2010-05-30 11:15:23 UTC (rev 42390)
@@ -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):
"""
@@ -302,8 +296,11 @@
def GetVectorNumberOfLayers(vector):
"""!Get list of vector layers"""
layers = list()
+ if not vector:
+ return layers
ret = gcmd.RunCommand('v.category',
+ flags = 'g',
read = True,
input = vector,
option = 'report')
@@ -312,14 +309,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