[GRASS-SVN] r65442 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 11 12:59:17 PDT 2015
Author: huhabla
Date: 2015-06-11 12:59:17 -0700 (Thu, 11 Jun 2015)
New Revision: 65442
Modified:
grass/trunk/lib/python/temporal/core.py
Log:
Show a warning if a temporal database connection is defined, but the database file is not present
Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py 2015-06-11 16:02:43 UTC (rev 65441)
+++ grass/trunk/lib/python/temporal/core.py 2015-06-11 19:59:17 UTC (rev 65442)
@@ -437,6 +437,7 @@
database) are the values
"""
global c_library_interface
+ global message_interface
mapsets = c_library_interface.available_mapsets()
@@ -447,8 +448,18 @@
database = c_library_interface.get_database_name(mapset)
if driver and database:
- tgis_mapsets[mapset] = (driver, database)
+ # Check if the temporal sqlite database exists
+ # We need to set non-existing databases in case the mapset is the current mapset
+ # to create it
+ if (driver == "sqlite" and os.path.exists(database)) or mapset == get_current_mapset() :
+ tgis_mapsets[mapset] = (driver, database)
+ # We need to warn if the connection is defined but the database does not
+ # exists
+ if driver == "sqlite" and not os.path.exists(database):
+ message_interface.warning("Temporal database connection defined as:\n" + \
+ database + "\nBut database file does not exists.")
+
return tgis_mapsets
###############################################################################
@@ -769,7 +780,7 @@
"postgresql_indexes.sql"), 'r').read()
# Connect now to the database
- if not dbif.connected:
+ if dbif.connected is not True:
dbif.connect()
# Execute the SQL statements for sqlite
@@ -879,7 +890,7 @@
driver, dbstring = self.tgis_mapsets[mapset]
conn = self.connections[mapset]
if conn.is_connected() is False:
- conn .connect(dbstring)
+ conn.connect(dbstring)
self.connected = True
More information about the grass-commit
mailing list