[GRASS-SVN] r67524 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 9 02:10:24 PST 2016


Author: martinl
Date: 2016-01-09 02:10:24 -0800 (Sat, 09 Jan 2016)
New Revision: 67524

Modified:
   grass/trunk/lib/python/script/db.py
Log:
pythonlib: fix db_connection(True) when default DB connection is not defined

Modified: grass/trunk/lib/python/script/db.py
===================================================================
--- grass/trunk/lib/python/script/db.py	2016-01-08 20:47:30 UTC (rev 67523)
+++ grass/trunk/lib/python/script/db.py	2016-01-09 10:10:24 UTC (rev 67524)
@@ -104,9 +104,13 @@
 
     :return: parsed output of db.connect
     """
-    nuldev = file(os.devnull, 'w')
-    conn = parse_command('db.connect', flags='g', stderr=nuldev)
-    nuldev.close()
+    try:
+        nuldev = file(os.devnull, 'w')
+        conn = parse_command('db.connect', flags='g', stderr=nuldev)
+        nuldev.close()
+    except CalledModuleError:
+        conn = None
+    
     if not conn and force:
         run_command('db.connect', flags='c')
         conn = parse_command('db.connect', flags='g')



More information about the grass-commit mailing list