[GRASS-SVN] r70373 - grass/trunk/scripts/v.db.addtable

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 15 02:33:02 PST 2017


Author: martinl
Date: 2017-01-15 02:33:02 -0800 (Sun, 15 Jan 2017)
New Revision: 70373

Modified:
   grass/trunk/scripts/v.db.addtable/v.db.addtable.py
Log:
v.db.addtable: fails gracefully when vector is open level 1

Modified: grass/trunk/scripts/v.db.addtable/v.db.addtable.py
===================================================================
--- grass/trunk/scripts/v.db.addtable/v.db.addtable.py	2017-01-14 17:34:55 UTC (rev 70372)
+++ grass/trunk/scripts/v.db.addtable/v.db.addtable.py	2017-01-15 10:33:02 UTC (rev 70373)
@@ -86,7 +86,7 @@
         grass.verbose(_("Using user specified table name: %s") % table)
 
     # check if DB parameters are set, and if not set them.
-    grass.run_command('db.connect', flags='c')
+    grass.run_command('db.connect', flags='c', quiet=True)
     grass.verbose(_("Creating new DB connection based on default mapset settings..."))
     kv = grass.db_connection()
     database = kv['database']
@@ -133,10 +133,17 @@
                       map=map_name, database=database, driver=driver,
                       layer=layer, table=table, key=key)
 
-    # finally we have to add cats into the attribute DB to make modules such as v.what.rast happy:
-    # (creates new row for each vector line):
-    grass.run_command('v.to.db', map=map_name, layer=layer,
-                      option='cat', column=key, qlayer=layer)
+    # finally we have to add cats into the attribute DB to make
+    # modules such as v.what.rast happy: (creates new row for each
+    # vector line):
+    try:
+        grass.run_command('v.to.db', map=map_name, layer=layer,
+                          option='cat', column=key, qlayer=layer)
+    except CalledModuleError:
+        # remove link
+        grass.run_command('v.db.connect', quiet=True, flags='d',
+                          map=map_name, layer=layer)
+        return 1
 
     grass.verbose(_("Current attribute table links:"))
     if grass.verbosity() > 2:



More information about the grass-commit mailing list