[GRASS-SVN] r62789 - in grass/branches/releasebranch_7_0: . gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 17 18:58:08 PST 2014


Author: wenzeslaus
Date: 2014-11-17 18:58:08 -0800 (Mon, 17 Nov 2014)
New Revision: 62789

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: handle CalledModuleError coming from checking db connection in d.vect dialog (backport of r62691 which replaces r62614, #2326, #2474, author: annakrat)


Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:60817,61096,61141,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62705,62709,62723,62730,62739,62741,62743,62746,62750,62752,62757,62762
   + /grass/trunk:60817,61096,61141,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62691,62705,62709,62723,62730,62739,62741,62743,62746,62750,62752,62757,62762

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/gselect.py	2014-11-18 02:40:19 UTC (rev 62788)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/gselect.py	2014-11-18 02:58:08 UTC (rev 62789)
@@ -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