[GRASS-SVN] r67525 - grass/branches/releasebranch_7_0/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 9 02:12:34 PST 2016


Author: martinl
Date: 2016-01-09 02:12:34 -0800 (Sat, 09 Jan 2016)
New Revision: 67525

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


Modified: grass/branches/releasebranch_7_0/lib/python/script/db.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/script/db.py	2016-01-09 10:10:24 UTC (rev 67524)
+++ grass/branches/releasebranch_7_0/lib/python/script/db.py	2016-01-09 10:12:34 UTC (rev 67525)
@@ -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