[GRASS-SVN] r53482 - in grass/trunk: gui/wxpython/gui_core include/Make lib/python/temporal temporal/t.create temporal/t.info temporal/t.list temporal/t.rast.aggregate temporal/t.rast.aggregate.ds temporal/t.rast.export temporal/t.rast.extract temporal/t.rast.gapfill temporal/t.rast.import temporal/t.rast.list temporal/t.rast.mapcalc temporal/t.rast.out.vtk temporal/t.rast.series temporal/t.rast.to.rast3 temporal/t.rast.univar temporal/t.rast3d.extract temporal/t.rast3d.list temporal/t.rast3d.mapcalc temporal/t.rast3d.univar temporal/t.register temporal/t.remove temporal/t.sample temporal/t.support temporal/t.topology temporal/t.unregister temporal/t.vect.db.select temporal/t.vect.export temporal/t.vect.extract temporal/t.vect.import temporal/t.vect.list temporal/t.vect.observe.strds temporal/t.vect.univar temporal/t.vect.what.strds

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 18 18:26:50 PDT 2012


Author: huhabla
Date: 2012-10-18 18:26:48 -0700 (Thu, 18 Oct 2012)
New Revision: 53482

Modified:
   grass/trunk/gui/wxpython/gui_core/gselect.py
   grass/trunk/include/Make/Grass.make
   grass/trunk/lib/python/temporal/abstract_dataset.py
   grass/trunk/lib/python/temporal/abstract_map_dataset.py
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/base.py
   grass/trunk/lib/python/temporal/core.py
   grass/trunk/lib/python/temporal/space_time_datasets_tools.py
   grass/trunk/lib/python/temporal/stds_import.py
   grass/trunk/temporal/t.create/t.create.py
   grass/trunk/temporal/t.info/t.info.py
   grass/trunk/temporal/t.list/t.list.py
   grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py
   grass/trunk/temporal/t.rast.aggregate/t.rast.aggregate.py
   grass/trunk/temporal/t.rast.export/t.rast.export.py
   grass/trunk/temporal/t.rast.extract/t.rast.extract.py
   grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py
   grass/trunk/temporal/t.rast.import/t.rast.import.py
   grass/trunk/temporal/t.rast.list/t.rast.list.py
   grass/trunk/temporal/t.rast.mapcalc/t.rast.mapcalc.py
   grass/trunk/temporal/t.rast.out.vtk/t.rast.out.vtk.py
   grass/trunk/temporal/t.rast.series/t.rast.series.py
   grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
   grass/trunk/temporal/t.rast.univar/t.rast.univar.py
   grass/trunk/temporal/t.rast3d.extract/t.rast3d.extract.py
   grass/trunk/temporal/t.rast3d.list/t.rast3d.list.py
   grass/trunk/temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py
   grass/trunk/temporal/t.rast3d.univar/t.rast3d.univar.py
   grass/trunk/temporal/t.register/t.register.py
   grass/trunk/temporal/t.remove/t.remove.py
   grass/trunk/temporal/t.sample/t.sample.py
   grass/trunk/temporal/t.support/t.support.py
   grass/trunk/temporal/t.topology/t.topology.py
   grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
   grass/trunk/temporal/t.topology/test.t.topology.reltime.sh
   grass/trunk/temporal/t.unregister/t.unregister.py
   grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py
   grass/trunk/temporal/t.vect.export/t.vect.export.py
   grass/trunk/temporal/t.vect.extract/t.vect.extract.py
   grass/trunk/temporal/t.vect.import/t.vect.import.py
   grass/trunk/temporal/t.vect.list/t.vect.list.py
   grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py
   grass/trunk/temporal/t.vect.univar/t.vect.univar.py
   grass/trunk/temporal/t.vect.what.strds/t.vect.what.strds.py
Log:
Modified initialization procedure of the temporal Python library
and removed unnecessary module calls while importing the 
database backend modules.


Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -163,6 +163,8 @@
         self.fullyQualified = True
         
         self.SetFilter(None)
+
+        tgis.init()
         
     def Create(self, parent):
         self.seltree = wx.TreeCtrl(parent, style=wx.TR_HIDE_ROOT

Modified: grass/trunk/include/Make/Grass.make
===================================================================
--- grass/trunk/include/Make/Grass.make	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/include/Make/Grass.make	2012-10-19 01:26:48 UTC (rev 53482)
@@ -169,7 +169,7 @@
 	SQLP:sqlp \
 	STATS:stats \
 	SYMB:symb \
-        TEMPORAL:temporal \
+	TEMPORAL:temporal \
 	VECTOR:vector \
 	VEDIT:vedit \
 	NETA:neta \

Modified: grass/trunk/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_dataset.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/abstract_dataset.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -49,6 +49,8 @@
 class AbstractDataset(object):
     """!This is the base class for all datasets 
        (raster, vector, raster3d, strds, stvds, str3ds)"""
+    def __init__(self):
+        pass
 
     def reset(self, ident):
         """!Reset the internal structure and set the identifier
@@ -231,7 +233,7 @@
                 dbif)
         statement += self.spatial_extent.get_insert_statement_mogrified(dbif)
         statement += self.metadata.get_insert_statement_mogrified(dbif)
-
+        
         if execute:
             dbif.execute_transaction(statement)
             if connect:

Modified: grass/trunk/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_map_dataset.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/abstract_map_dataset.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -66,6 +66,7 @@
     """
 
     def __init__(self):
+        AbstractDataset.__init__(self)
         self.reset_temporal_topology()
 
     def reset_temporal_topology(self):

Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -32,6 +32,7 @@
        collecting of metadata.
     """
     def __init__(self, ident):
+        AbstractDataset.__init__(self)
         self.reset(ident)
         self.map_counter = 0
 
@@ -1018,7 +1019,7 @@
 
         # Check if map is already registered
         if stds_register_table is not None:
-            if dbmi.paramstyle == "qmark":
+            if dbif.dbmi.paramstyle == "qmark":
                 sql = "SELECT id FROM " + \
                     stds_register_table + " WHERE id = (?)"
             else:
@@ -1115,7 +1116,7 @@
 
         # Register the stds in the map stds register table
         # Check if the entry is already there
-        if dbmi.paramstyle == "qmark":
+        if dbif.dbmi.paramstyle == "qmark":
             sql = "SELECT id FROM " + map_register_table + " WHERE id = ?"
         else:
             sql = "SELECT id FROM " + map_register_table + " WHERE id = %s"
@@ -1127,7 +1128,7 @@
 
         # In case of no entry make a new one
         if row is None:
-            if dbmi.paramstyle == "qmark":
+            if dbif.dbmi.paramstyle == "qmark":
                 sql = "INSERT INTO " + map_register_table + \
                     " (id) " + "VALUES (?);\n"
             else:
@@ -1138,7 +1139,7 @@
                 (sql, (self.base.get_id(),)))
 
         # Now put the raster name in the stds map register table
-        if dbmi.paramstyle == "qmark":
+        if dbif.dbmi.paramstyle == "qmark":
             sql = "INSERT INTO " + stds_register_table + \
                 " (id) " + "VALUES (?);\n"
         else:
@@ -1193,7 +1194,7 @@
 
         # Check if the map is registered in the space time raster dataset
         if map_register_table is not None:
-            if dbmi.paramstyle == "qmark":
+            if dbif.dbmi.paramstyle == "qmark":
                 sql = "SELECT id FROM " + map_register_table + " WHERE id = ?"
             else:
                 sql = "SELECT id FROM " + map_register_table + " WHERE id = %s"
@@ -1220,7 +1221,7 @@
 
         # Remove the space time raster dataset from the raster dataset register
         if map_register_table is not None:
-            if dbmi.paramstyle == "qmark":
+            if dbif.dbmi.paramstyle == "qmark":
                 sql = "DELETE FROM " + map_register_table + " WHERE id = ?;\n"
             else:
                 sql = "DELETE FROM " + map_register_table + " WHERE id = %s;\n"
@@ -1230,7 +1231,7 @@
 
         # Remove the raster map from the space time raster dataset register
         if stds_register_table is not None:
-            if dbmi.paramstyle == "qmark":
+            if dbif.dbmi.paramstyle == "qmark":
                 sql = "DELETE FROM " + stds_register_table + " WHERE id = ?;\n"
             else:
                 sql = "DELETE FROM " + \
@@ -1353,7 +1354,7 @@
 
             if row is not None:
                 # This seems to be a bug in sqlite3 Python driver
-                if dbmi.__name__ == "sqlite3":
+                if dbif.dbmi.__name__ == "sqlite3":
                     tstring = row[0]
                     # Convert the unicode string into the datetime format
                     if self.is_time_absolute():

Modified: grass/trunk/lib/python/temporal/base.py
===================================================================
--- grass/trunk/lib/python/temporal/base.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/base.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -40,6 +40,7 @@
 class DictSQLSerializer(object):
     def __init__(self):
         self.D = {}
+        self.dbif =  SQLDatabaseInterfaceConnection()
 
     def serialize(self, type, table, where=None):
         """!Convert the internal dictionary into a string of semicolon 
@@ -107,12 +108,12 @@
             sql += ') VALUES ('
             for key in self.D.keys():
                 if count == 0:
-                    if dbmi.paramstyle == "qmark":
+                    if self.dbif.dbmi.paramstyle == "qmark":
                         sql += '?'
                     else:
                         sql += '%s'
                 else:
-                    if dbmi.paramstyle == "qmark":
+                    if self.dbif.dbmi.paramstyle == "qmark":
                         sql += ' ,?'
                     else:
                         sql += ' ,%s'
@@ -132,13 +133,13 @@
                 # Update only entries which are not None
                 if self.D[key] is not None:
                     if count == 0:
-                        if dbmi.paramstyle == "qmark":
+                        if self.dbif.dbmi.paramstyle == "qmark":
                             sql += ' %s = ? ' % key
                         else:
                             sql += ' %s ' % key
                             sql += '= %s '
                     else:
-                        if dbmi.paramstyle == "qmark":
+                        if self.dbif.dbmi.paramstyle == "qmark":
                             sql += ' ,%s = ? ' % key
                         else:
                             sql += ' ,%s ' % key
@@ -155,13 +156,13 @@
             sql += 'UPDATE ' + table + ' SET '
             for key in self.D.keys():
                 if count == 0:
-                    if dbmi.paramstyle == "qmark":
+                    if self.dbif.dbmi.paramstyle == "qmark":
                         sql += ' %s = ? ' % key
                     else:
                         sql += ' %s ' % key
                         sql += '= %s '
                 else:
-                    if dbmi.paramstyle == "qmark":
+                    if self.dbif.dbmi.paramstyle == "qmark":
                         sql += ' ,%s = ? ' % key
                     else:
                         sql += ' ,%s ' % key

Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/core.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -36,8 +36,26 @@
 """
 import os
 import copy
+import sys
 import grass.script.core as core
+# Import all supported database backends
+try:
+    import sqlite3
+except ImportError:
+    raise
+# Postgresql is optional, existence is checked when needed
+try:
+    import psycopg2
+    import psycopg2.extras
+except:
+    pass
 
+# Global variable that defines the backend
+# of the temporal GIS
+# It can either be "sqlite" or "pg"
+tgis_backed = None
+
+
 # This variable specifies if the ctypes interface to the grass 
 # libraries should be used to read map specific data. If set to False
 # the grass scripting library will be used to get map informations.
@@ -45,34 +63,14 @@
 # the GRASS C functions may call G_fatal_error() which exits the process.
 # That is not catchable in Python.
 use_ctypes_map_access = True
-
+        
 ###############################################################################
 
-# The chosen DBMI back-end can be defined on runtime
-# Check the grass environment before import
-core.run_command("t.connect", flags="c")
-kv = core.parse_command("t.connect", flags="pg")
-if "driver" in kv:
-    if kv["driver"] == "sqlite":
-        import sqlite3 as dbmi
-    elif kv["driver"] == "pg":
-        import psycopg2 as dbmi
-        # Needed for dictionary like cursors
-        import psycopg2.extras
-    else:
-        core.fatal(_("Unable to initialize the temporal DBMI interface. Use "
-                     "t.connect to specify the driver and the database string"))
-else:
-    # Use the default sqlite variable
-    core.run_command("t.connect", flags="d")
-    import sqlite3 as dbmi
-
-###############################################################################
-
 def get_temporal_dbmi_init_string():
     kv = core.parse_command("t.connect", flags="pg")
     grassenv = core.gisenv()
-    if dbmi.__name__ == "sqlite3":
+    global tgis_backed
+    if tgis_backed == "sqlite":
         if "database" in kv:
             string = kv["database"]
             string = string.replace("$GISDBASE", grassenv["GISDBASE"])
@@ -83,15 +81,14 @@
             core.fatal(_("Unable to initialize the temporal GIS DBMI "
                          "interface. Use t.connect to specify the driver "
                          "and the database string"))
-    elif dbmi.__name__ == "psycopg2":
+    elif tgis_backed == "pg":
         if "database" in kv:
             string = kv["database"]
             return string
-        else:
-            core.fatal(_("Unable to initialize the temporal GIS DBMI "
-                         "interface. Use t.connect to specify the driver "
-                         "and the database string"))
-            return "dbname=grass_test user=soeren password=abcdefgh"
+    else:
+        core.fatal(_("Unable to initialize the temporal GIS DBMI "
+                     "interface. Use t.connect to specify the driver "
+                     "and the database string"))
 
 ###############################################################################
 
@@ -112,6 +109,13 @@
 
 ###############################################################################
 
+def get_use_ctypes_map_access(use_ctype = True):
+    """!Return true if ctypes is used for map access """
+    global use_ctypes_map_access
+    return use_ctypes_map_access
+
+###############################################################################
+
 def get_sql_template_path():
     base = os.getenv("GISBASE")
     base_etc = os.path.join(base, "etc")
@@ -119,25 +123,61 @@
 
 ###############################################################################
 
-def create_temporal_database():
-    """!This function creates the grass location database structure for raster, 
+def init():
+    """!This function set the correct database backend from the environmental variables
+       and creates the grass location database structure for raster, 
        vector and raster3d maps as well as for the space-time datasets strds, 
-       str3ds and stvds
+       str3ds and stvds in case it not exists.
 
-       This functions must be called before any spatio-temporal processing 
-       can be started
+        ATTENTION: This functions must be called before any spatio-temporal processing 
+                   can be started
     """
+    # We need to set the correct database backend from the environment variables
+    global tgis_backed
+    
+    dbmi = sqlite3
 
+    core.run_command("t.connect", flags="c")
+    kv = core.parse_command("t.connect", flags="pg")
+    
+    if "driver" in kv:
+        if kv["driver"] == "sqlite":
+            tgis_backed = kv["driver"]
+        elif kv["driver"] == "pg":
+            tgis_backed = kv["driver"]
+            try:
+                import psycopg2
+            except ImportError:
+                core.error("Unable to locate the Postgresql SQL Python interface module psycopg2.")
+                raise
+            dbmi = psycopg2
+        else:
+            core.fatal(_("Unable to initialize the temporal DBMI interface. Use "
+                         "t.connect to specify the driver and the database string"))
+    else:
+        # Set the default sqlite3 connection in case nothing was defined
+        core.run_command("t.connect", flags="d")
+            
     database = get_temporal_dbmi_init_string()
 
     db_exists = False
 
     # Check if the database already exists
-    if dbmi.__name__ == "sqlite3":
+    if tgis_backed == "sqlite":
         # Check path of the sqlite database
         if os.path.exists(database):
-            db_exists = True
-    elif dbmi.__name__ == "psycopg2":
+            # Connect to database
+            connection = dbmi.connect(database)
+            cursor = connection.cursor()
+            # Check for raster_base table
+            cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='raster_base';")
+            
+            name = cursor.fetchone()[0]
+            if name == "raster_base":
+                db_exists = True
+            connection.commit()
+            cursor.close()
+    elif tgis_backed == "pg":
         # Connect to database
         connection = dbmi.connect(database)
         cursor = connection.cursor()
@@ -186,7 +226,7 @@
     connection = dbmi.connect(database)
     cursor = connection.cursor()
 
-    if dbmi.__name__ == "sqlite3":
+    if tgis_backed == "sqlite":
 
         sqlite3_delete_trigger_sql = open(os.path.join(get_sql_template_path(
         ), "sqlite3_delete_trigger.sql"), 'r').read()
@@ -207,7 +247,7 @@
         cursor.executescript(str3ds_tables_sql)
         cursor.executescript(str3ds_metadata_sql)
         cursor.executescript(sqlite3_delete_trigger_sql)
-    elif dbmi.__name__ == "psycopg2":
+    elif tgis_backed == "pg":
         # Execute the SQL statements for postgresql
         # Create the global tables for the native grass datatypes
         cursor.execute(raster_tables_sql)
@@ -240,6 +280,11 @@
     """
     def __init__(self):
         self.connected = False
+        global tgis_backend
+        if tgis_backed == "sqlite":
+            self.dbmi = sqlite3
+        else:
+            self.dbmi = psycopg2
 
     def connect(self):
         """!Connect to the DBMI to execute SQL statements
@@ -248,19 +293,19 @@
         """
         init = get_temporal_dbmi_init_string()
         #print "Connect to",  self.database
-        if dbmi.__name__ == "sqlite3":
-            self.connection = dbmi.connect(init, 
-                    detect_types=dbmi.PARSE_DECLTYPES | dbmi.PARSE_COLNAMES)
-            self.connection.row_factory = dbmi.Row
+        if self.dbmi.__name__ == "sqlite3":
+            self.connection = self.dbmi.connect(init, 
+                    detect_types = self.dbmi.PARSE_DECLTYPES | self.dbmi.PARSE_COLNAMES)
+            self.connection.row_factory = self.dbmi.Row
             self.connection.isolation_level = None
             self.cursor = self.connection.cursor()
             self.cursor.execute("PRAGMA synchronous = OFF")
             self.cursor.execute("PRAGMA journal_mode = MEMORY")
-        elif dbmi.__name__ == "psycopg2":
-            self.connection = dbmi.connect(init)
+        elif self.dbmi.__name__ == "psycopg2":
+            self.connection = self.dbmi.connect(init)
             #self.connection.set_isolation_level(dbmi.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
             self.cursor = self.connection.cursor(
-                cursor_factory=dbmi.extras.DictCursor)
+                cursor_factory = self.dbmi.extras.DictCursor)
         self.connected = True
 
     def close(self):
@@ -291,8 +336,8 @@
         """
         sql = content[0]
         args = content[1]
-
-        if dbmi.__name__ == "psycopg2":
+        
+        if self.dbmi.__name__ == "psycopg2":
             if len(args) == 0:
                 return sql
             else:
@@ -308,7 +353,7 @@
                     self.close()
                     return statement
 
-        elif dbmi.__name__ == "sqlite3":
+        elif self.dbmi.__name__ == "sqlite3":
             if len(args) == 0:
                 return sql
             else:
@@ -366,7 +411,7 @@
         sql_script += "END TRANSACTION;"
         
         try:
-            if dbmi.__name__ == "sqlite3":
+            if self.dbmi.__name__ == "sqlite3":
                 self.cursor.executescript(statement)
             else:
                 self.cursor.execute(statement)

Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -274,7 +274,7 @@
             statement += map.insert(dbif=dbif, execute=False)
 
         # Sqlite3 performace better for huge datasets when committing in small chunks
-        if dbmi.__name__ == "sqlite3":
+        if dbif.dbmi.__name__ == "sqlite3":
             if count % 100 == 0:
                 if statement is not None and statement != "":
                     core.message(_("Registering maps in the temporal database")

Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/lib/python/temporal/stds_import.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -39,6 +39,7 @@
 import tempfile
 import time
 import filecmp
+import space_time_datasets_tools
 from space_time_datasets_tools import *
 
 proj_file_name = "proj.txt"
@@ -248,7 +249,7 @@
 
     try:
         # Make sure the temporal database exists
-        create_temporal_database()
+        space_time_datasets_tools.init()
 
         fs = "|"
         maplist = []

Modified: grass/trunk/temporal/t.create/t.create.py
===================================================================
--- grass/trunk/temporal/t.create/t.create.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.create/t.create.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -72,9 +72,8 @@
     descr = options["description"]
     semantic = options["semantictype"]
 
-    # Make sure the temporal database exists
-    tgis.create_temporal_database()
-
+    tgis.init()
+    
     #Get the current mapset to create the id of the space time dataset
 
     mapset = grass.gisenv()["MAPSET"]

Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.info/t.info.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -62,12 +62,14 @@
     system = flags['s']
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
+    
+    dbif = tgis.SQLDatabaseInterfaceConnection()
 
     if system and not shellstyle:
         #      0123456789012345678901234567890
         print " +------------------- Temporal DBMI backend information ----------------------+"
-        print " | DBMI Python interface:...... " + str(tgis.dbmi.__name__)
+        print " | DBMI Python interface:...... " + str(dbif.dbmi.__name__)
         print " | DBMI init string:........... " + str(
             tgis.get_temporal_dbmi_init_string())
         print " | SQL template path:.......... " + str(
@@ -75,7 +77,7 @@
         print " +----------------------------------------------------------------------------+"
         return
     elif system:
-        print "dbmi_python_interface=" + str(tgis.dbmi.__name__)
+        print "dbmi_python_interface=" + str(dbif.dbmi.__name__)
         print "dbmi_init_string=" + str(tgis.get_temporal_dbmi_init_string())
         print "sql_template_path=" + str(tgis.get_sql_template_path())
         return

Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.list/t.list.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -88,7 +88,7 @@
     colhead = flags['c']
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     id = None
     sp = tgis.dataset_factory(type, id)

Modified: grass/trunk/temporal/t.rast.aggregate/t.rast.aggregate.py
===================================================================
--- grass/trunk/temporal/t.rast.aggregate/t.rast.aggregate.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.aggregate/t.rast.aggregate.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -83,7 +83,7 @@
     sampling = options["sampling"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()

Modified: grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py
===================================================================
--- grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -81,7 +81,7 @@
     sampling = options["sampling"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()

Modified: grass/trunk/temporal/t.rast.export/t.rast.export.py
===================================================================
--- grass/trunk/temporal/t.rast.export/t.rast.export.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.export/t.rast.export.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -73,7 +73,7 @@
     _format = options["format"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # Export the space time raster dataset
     tgis.export_stds(
         _input, output, compression, workdir, where, _format, "strds")

Modified: grass/trunk/temporal/t.rast.extract/t.rast.extract.py
===================================================================
--- grass/trunk/temporal/t.rast.extract/t.rast.extract.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.extract/t.rast.extract.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -79,7 +79,7 @@
     register_null = flags["n"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.extract_dataset(input, output, "raster", where, expression,
                          base, nprocs, register_null)

Modified: grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py
===================================================================
--- grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -64,7 +64,7 @@
     nprocs = options["nprocs"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     if input.find("@") >= 0:
         id = input

Modified: grass/trunk/temporal/t.rast.import/t.rast.import.py
===================================================================
--- grass/trunk/temporal/t.rast.import/t.rast.import.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.import/t.rast.import.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -92,6 +92,8 @@
     exp = flags["e"]
     overr = flags["o"]
     create = flags["c"]
+    
+    tgis.init()
 
     tgis.import_stds(input, output, extrdir, title, descr, location,
                      link, exp, overr, create, "strds")

Modified: grass/trunk/temporal/t.rast.list/t.rast.list.py
===================================================================
--- grass/trunk/temporal/t.rast.list/t.rast.list.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.list/t.rast.list.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -88,7 +88,7 @@
     header = flags["h"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.list_maps_of_stds(
         "strds", input, columns, order, where, separator, method, header)

Modified: grass/trunk/temporal/t.rast.mapcalc/t.rast.mapcalc.py
===================================================================
--- grass/trunk/temporal/t.rast.mapcalc/t.rast.mapcalc.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.mapcalc/t.rast.mapcalc.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -91,7 +91,7 @@
     method = method.split(",")
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.dataset_mapcalculator(inputs, output, "raster", expression,
                                base, method, nprocs, register_null, spatial)

Modified: grass/trunk/temporal/t.rast.out.vtk/t.rast.out.vtk.py
===================================================================
--- grass/trunk/temporal/t.rast.out.vtk/t.rast.out.vtk.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.out.vtk/t.rast.out.vtk.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -84,7 +84,7 @@
     use_granularity = flags["g"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     if not os.path.exists(expdir):
         grass.fatal(_("Export directory <%s> not found.") % expdir)

Modified: grass/trunk/temporal/t.rast.series/t.rast.series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/t.rast.series.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.series/t.rast.series.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -71,7 +71,7 @@
     add_time = flags["t"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     if input.find("@") >= 0:
         id = input

Modified: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -42,7 +42,7 @@
     output = options["output"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     mapset = grass.gisenv()["MAPSET"]
 

Modified: grass/trunk/temporal/t.rast.univar/t.rast.univar.py
===================================================================
--- grass/trunk/temporal/t.rast.univar/t.rast.univar.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast.univar/t.rast.univar.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -61,7 +61,7 @@
     fs = options["fs"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.print_gridded_dataset_univar_statistics(
         "strds", input, where, extended, header, fs)

Modified: grass/trunk/temporal/t.rast3d.extract/t.rast3d.extract.py
===================================================================
--- grass/trunk/temporal/t.rast3d.extract/t.rast3d.extract.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast3d.extract/t.rast3d.extract.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -77,7 +77,7 @@
     register_null = flags["n"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.extract_dataset(input, output, "raster3d", where, expression,
                          base, nprocs, register_null)

Modified: grass/trunk/temporal/t.rast3d.list/t.rast3d.list.py
===================================================================
--- grass/trunk/temporal/t.rast3d.list/t.rast3d.list.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast3d.list/t.rast3d.list.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -88,7 +88,7 @@
     header = flags["h"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.list_maps_of_stds(
         "str3ds", input, columns, order, where, separator, method, header)

Modified: grass/trunk/temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py
===================================================================
--- grass/trunk/temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -90,7 +90,7 @@
     method = method.split(",")
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.dataset_mapcalculator(inputs, output, "raster3d", expression,
                                base, method, nprocs, register_null, spatial)

Modified: grass/trunk/temporal/t.rast3d.univar/t.rast3d.univar.py
===================================================================
--- grass/trunk/temporal/t.rast3d.univar/t.rast3d.univar.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.rast3d.univar/t.rast3d.univar.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -61,7 +61,7 @@
     fs = options["fs"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.print_gridded_dataset_univar_statistics(
         "str3ds", input, where, extended, header, fs)

Modified: grass/trunk/temporal/t.register/t.register.py
===================================================================
--- grass/trunk/temporal/t.register/t.register.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.register/t.register.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -104,7 +104,7 @@
     interval = flags["i"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # Register maps
     tgis.register_maps_in_space_time_dataset(
         type=type, name=name, maps=maps, file=file, start=start, end=end,

Modified: grass/trunk/temporal/t.remove/t.remove.py
===================================================================
--- grass/trunk/temporal/t.remove/t.remove.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.remove/t.remove.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -59,7 +59,7 @@
         core.fata(_("%s= and %s= are mutually exclusive") % ("input", "file"))
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()

Modified: grass/trunk/temporal/t.sample/t.sample.py
===================================================================
--- grass/trunk/temporal/t.sample/t.sample.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.sample/t.sample.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -81,7 +81,7 @@
     method = method.split(",")
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.sample_stds_by_stds_topology(intype, samtype, inputs, sampler,
                                       header, separator, method, spatial)

Modified: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.support/t.support.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -80,7 +80,7 @@
     map_update = flags["m"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     #Get the current mapset to create the id of the space time dataset
     mapset = grass.gisenv()["MAPSET"]

Modified: grass/trunk/temporal/t.topology/t.topology.py
===================================================================
--- grass/trunk/temporal/t.topology/t.topology.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.topology/t.topology.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -49,7 +49,7 @@
     tmatrix = flags['m']
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     #Get the current mapset to create the id of the space time dataset
     if name.find("@") >= 0:

Modified: grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
===================================================================
--- grass/trunk/temporal/t.topology/test.t.topology.abstime.sh	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.topology/test.t.topology.abstime.sh	2012-10-19 01:26:48 UTC (rev 53482)
@@ -83,32 +83,32 @@
 t.create --o type=strds temporaltype=absolute output=precip_abs title="A test with input files" descr="A test with input files"
 t.create --o type=strds temporaltype=absolute output=maps title="A test with maps in input files" descr="A test with maps in input files"
 
-t.register type=rast -i input=precip_abs file="${n1}" start="2001-01-01" increment="1 months"
+t.register --o type=rast -i input=precip_abs file="${n1}" start="2001-01-01" increment="1 months"
 cat "${n1}"
 t.topology    input=precip_abs
 t.topology -m input=precip_abs
 
-t.register type=rast -i input=precip_abs file="${n2}"
+t.register --o type=rast -i input=precip_abs file="${n2}"
 cat "${n2}"
 t.topology    input=precip_abs
 t.topology -m input=precip_abs
 
-t.register type=rast -i input=precip_abs file="${n3}"
+t.register --o type=rast -i input=precip_abs file="${n3}"
 cat "${n3}"
 t.topology    input=precip_abs
 t.topology -m input=precip_abs
 
-t.register type=rast -i input=precip_abs file="${n4}"
+t.register --o type=rast -i input=precip_abs file="${n4}"
 cat "${n4}"
 t.topology    input=precip_abs
 t.topology -m input=precip_abs
 
-t.register type=rast -i input=precip_abs file="${n5}"
+t.register --o type=rast -i input=precip_abs file="${n5}"
 cat "${n5}"
 t.topology    input=precip_abs
 t.topology -m input=precip_abs
 
-t.register type=rast -i input=maps file="${n6}"
+t.register --o type=rast -i input=maps file="${n6}"
 cat "${n6}"
 t.topology    input=maps
 t.topology -m input=maps

Modified: grass/trunk/temporal/t.topology/test.t.topology.reltime.sh
===================================================================
--- grass/trunk/temporal/t.topology/test.t.topology.reltime.sh	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.topology/test.t.topology.reltime.sh	2012-10-19 01:26:48 UTC (rev 53482)
@@ -70,27 +70,27 @@
 t.create --o type=strds temporaltype=relative output=precip_rel_d title="A test with input files of unti days" descr="A test with input files"
 t.create --o type=strds temporaltype=relative output=precip_rel_y title="A test with input files of unit years" descr="A test with input files"
 
-t.register type=rast -i --v input=precip_rel_d file="${n1}" start=0 increment=1 unit=days
+t.register --o type=rast -i --v input=precip_rel_d file="${n1}" start=0 increment=1 unit=days
 cat "${n1}"
 t.topology    input=precip_rel_d
 t.topology -m input=precip_rel_d
 
-t.register type=rast -i input=precip_rel_d file="${n2}" unit=days
+t.register --o type=rast -i input=precip_rel_d file="${n2}" unit=days
 cat "${n2}"
 t.topology    input=precip_rel_d
 t.topology -m input=precip_rel_d
 
-t.register type=rast -i input=precip_rel_d file="${n3}" unit=days
+t.register --o type=rast -i input=precip_rel_d file="${n3}" unit=days
 cat "${n3}"
 t.topology    input=precip_rel_d
 t.topology -m input=precip_rel_d
 
-t.register type=rast -i input=precip_rel_y file="${n4}" unit=years
+t.register --o type=rast -i input=precip_rel_y file="${n4}" unit=years
 cat "${n4}"
 t.topology    input=precip_rel_y
 t.topology -m input=precip_rel_y
 
-t.register type=rast -i input=precip_rel_y file="${n5}" unit=years
+t.register --o type=rast -i input=precip_rel_y file="${n5}" unit=years
 cat "${n5}"
 t.topology    input=precip_rel_y
 t.topology -m input=precip_rel_y

Modified: grass/trunk/temporal/t.unregister/t.unregister.py
===================================================================
--- grass/trunk/temporal/t.unregister/t.unregister.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.unregister/t.unregister.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -55,7 +55,7 @@
     type = options["type"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     if maps and file:
         grass.fatal(_(

Modified: grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py
===================================================================
--- grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -71,7 +71,7 @@
         columns = None
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     mapset = grass.gisenv()["MAPSET"]
 

Modified: grass/trunk/temporal/t.vect.export/t.vect.export.py
===================================================================
--- grass/trunk/temporal/t.vect.export/t.vect.export.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.export/t.vect.export.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -73,7 +73,7 @@
     _format = options["format"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # Export the space time raster dataset
     tgis.export_stds(
         _input, output, compression, workdir, where, _format, "stvds")

Modified: grass/trunk/temporal/t.vect.extract/t.vect.extract.py
===================================================================
--- grass/trunk/temporal/t.vect.extract/t.vect.extract.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.extract/t.vect.extract.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -82,7 +82,7 @@
     register_null = flags["n"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.extract_dataset(input, output, "vector", where, expression,
                          base, nprocs, register_null, layer, type)

Modified: grass/trunk/temporal/t.vect.import/t.vect.import.py
===================================================================
--- grass/trunk/temporal/t.vect.import/t.vect.import.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.import/t.vect.import.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -86,6 +86,8 @@
     exp = flags["e"]
     overr = flags["o"]
     create = flags["c"]
+    
+    tgis.init()
 
     tgis.import_stds(input, output, extrdir, title, descr, location,
                      None, exp, overr, create, "stvds")

Modified: grass/trunk/temporal/t.vect.list/t.vect.list.py
===================================================================
--- grass/trunk/temporal/t.vect.list/t.vect.list.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.list/t.vect.list.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -87,7 +87,7 @@
     header = flags["h"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.list_maps_of_stds(
         "stvds", input, columns, order, where, separator, method, header)

Modified: grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py
===================================================================
--- grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -73,7 +73,7 @@
         where = None
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()

Modified: grass/trunk/temporal/t.vect.univar/t.vect.univar.py
===================================================================
--- grass/trunk/temporal/t.vect.univar/t.vect.univar.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.univar/t.vect.univar.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -82,7 +82,7 @@
     fs = options["fs"]
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
 
     tgis.print_vector_dataset_univar_statistics(
         input, twhere, layer, type, column, where, extended, header, fs)

Modified: grass/trunk/temporal/t.vect.what.strds/t.vect.what.strds.py
===================================================================
--- grass/trunk/temporal/t.vect.what.strds/t.vect.what.strds.py	2012-10-19 00:18:07 UTC (rev 53481)
+++ grass/trunk/temporal/t.vect.what.strds/t.vect.what.strds.py	2012-10-19 01:26:48 UTC (rev 53482)
@@ -79,7 +79,7 @@
         where = None
 
     # Make sure the temporal database exists
-    tgis.create_temporal_database()
+    tgis.init()
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()



More information about the grass-commit mailing list