[GRASS-SVN] r38313 - grass-addons/vector/v.in.postgis

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 8 08:43:18 EDT 2009


Author: mathieug
Date: 2009-07-08 08:43:17 -0400 (Wed, 08 Jul 2009)
New Revision: 38313

Modified:
   grass-addons/vector/v.in.postgis/v.in.postgis.py
Log:
exception handling for tests config

Modified: grass-addons/vector/v.in.postgis/v.in.postgis.py
===================================================================
--- grass-addons/vector/v.in.postgis/v.in.postgis.py	2009-07-08 12:32:46 UTC (rev 38312)
+++ grass-addons/vector/v.in.postgis/v.in.postgis.py	2009-07-08 12:43:17 UTC (rev 38313)
@@ -424,12 +424,16 @@
 flags = {'d':0, 'z':0, 'o':0, 'g':0, 'l':0}
 importer = GrassPostGisImporter(options, flags)
 ##test configuration
+testsConfigOk = True
 host = 'localhost'
 dbname = 'yourdb'
 user = 'pguser'
 pwd = 'yourpwd'
-db = dbapi2.connect(host=host, database=dbname, user=user, password=pwd)
-cursor = db.cursor()
+try:
+    db = dbapi2.connect(host=host, database=dbname, user=user, password=pwd)
+    cursor = db.cursor()
+except:
+    testsConfigOk = False
 testTableName = 'test_grass_import'
 queryTableName = 'test_query'
 geometryField = 'the_geom'
@@ -685,7 +689,11 @@
     #brk(host="localhost", port=9000)
     options, flags = grass.parser()
     if flags['t'] is True:
-        tests()
+        if testsConfigOk is True:
+            tests()
+        else:
+            grass.error("Could not connect to test database. Check the tests configuration.")
     else:
         main()
 
+



More information about the grass-commit mailing list