[GRASS-SVN] r63898 - grass/trunk/scripts/v.db.univar
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 1 06:07:44 PST 2015
Author: martinl
Date: 2015-01-01 06:07:44 -0800 (Thu, 01 Jan 2015)
New Revision: 63898
Modified:
grass/trunk/scripts/v.db.univar/v.db.univar.py
Log:
v.db.univar: check if map exists
catch error from db.univar
Modified: grass/trunk/scripts/v.db.univar/v.db.univar.py
===================================================================
--- grass/trunk/scripts/v.db.univar/v.db.univar.py 2015-01-01 14:06:44 UTC (rev 63897)
+++ grass/trunk/scripts/v.db.univar/v.db.univar.py 2015-01-01 14:07:44 UTC (rev 63898)
@@ -54,6 +54,7 @@
import sys
import os
import grass.script as grass
+from grass.exceptions import CalledModuleError
def main():
global tmp
@@ -67,7 +68,9 @@
extend = flags['e']
shellstyle = flags['g']
-
+ if not grass.find_file(vector, element='vector')['file']:
+ grass.fatal(_("Vector map <%s> not found") % vector)
+
fi = grass.vector_db(vector, stderr = nuldev)[int(layer)]
table = fi['table']
database = fi['database']
@@ -81,12 +84,14 @@
passflags = 'g'
else:
passflags = passflags + 'g'
+
+ try:
+ grass.run_command('db.univar', table = table, column = column,
+ database = database, driver = driver,
+ perc = perc, where = where, flags = passflags)
+ except CalledModuleError:
+ sys.exit(1)
- grass.run_command('db.univar', table = table, column = column,
- database = database, driver = driver,
- perc = perc, where = where, flags = passflags)
-
-
if __name__ == "__main__":
options, flags = grass.parser()
nuldev = file(os.devnull, 'w')
More information about the grass-commit
mailing list