[GRASS-SVN] r62691 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 10 07:29:52 PST 2014


Author: annakrat
Date: 2014-11-10 07:29:52 -0800 (Mon, 10 Nov 2014)
New Revision: 62691

Modified:
   grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: handle CalledModuleError coming from checking db connection in d.vect dialog

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2014-11-10 07:25:02 UTC (rev 62690)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2014-11-10 15:29:52 UTC (rev 62691)
@@ -52,6 +52,7 @@
 
 import grass.script as grass
 from   grass.script import task as gtask
+from grass.exceptions import CalledModuleError
 try:
     from grass.pygrass import messages
 except ImportError as e:
@@ -727,12 +728,14 @@
 
     def _CheckDBConnection(self):
         """Check DB connection"""
-        # if map is not defined (happens with vnet initialization)
-        if not self.map:
+        nuldev = file(os.devnull, 'w+')
+        # if map is not defined (happens with vnet initialization) or it doesn't exist
+        try:
+            self.layers = grass.vector_db(map=self.map, stderr=nuldev)
+        except CalledModuleError:
             return False
-        nuldev = file(os.devnull, 'w+')
-        self.layers = grass.vector_db(map = self.map, stderr = nuldev)
-        nuldev.close()
+        finally:  # always close nuldev
+            nuldev.close()
 
         return bool(len(self.layers.keys()) > 0)
 



More information about the grass-commit mailing list