[GRASS-SVN] r46985 - in grass/trunk/lib: db/dbmi_client init

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 5 06:18:09 EDT 2011


Author: martinl
Date: 2011-07-05 03:18:09 -0700 (Tue, 05 Jul 2011)
New Revision: 46985

Modified:
   grass/trunk/lib/db/dbmi_client/c_drop_tab.c
   grass/trunk/lib/db/dbmi_client/copy_tab.c
   grass/trunk/lib/init/grass.py
Log:
grass.py: clean_env() implemented - remove all %MONITOR% variables on exit


Modified: grass/trunk/lib/db/dbmi_client/c_drop_tab.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/c_drop_tab.c	2011-07-05 10:16:45 UTC (rev 46984)
+++ grass/trunk/lib/db/dbmi_client/c_drop_tab.c	2011-07-05 10:18:09 UTC (rev 46985)
@@ -1,17 +1,18 @@
 /*!
- * \file db/dbmi_client/c_drop_tab.c
- * 
- * \brief DBMI Library (client) - drop table
- *
- * (C) 1999-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author Joel Jones (CERL/UIUC), Radim Blazek
- */
+  \file db/dbmi_client/c_drop_tab.c
+ 
+ \brief DBMI Library (client) - drop table
+ 
+ (C) 1999-2008, 2011 by the GRASS Development Team
+ 
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
 
+ \author Joel Jones (CERL/UIUC)
+ \author Radim Blazek
+*/
+
 #include <grass/dbmi.h>
 #include "macros.h"
 

Modified: grass/trunk/lib/db/dbmi_client/copy_tab.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/copy_tab.c	2011-07-05 10:16:45 UTC (rev 46984)
+++ grass/trunk/lib/db/dbmi_client/copy_tab.c	2011-07-05 10:18:09 UTC (rev 46985)
@@ -31,7 +31,7 @@
 }
 
 /*!
-  \brief Copy table, used by various db_copy_table*
+  \brief Copy table, used by various db_copy_table* (internal use only)
   
   Use either 'where' or 'select' or 'selcol'+'ivals'+'nvals' but
   never more than one.
@@ -160,15 +160,27 @@
 
     for (i = 0; i < count; i++) {
 	const char *tblname = db_get_string(&tblnames[i]);
-
+	int ret;
+	
+	ret = DB_FAILED;
 	if (strcmp(to_tblname, tblname) == 0) {
-	    G_warning(_("Table <%s> already exists in database <%s>"),
-		      to_tblname, to_dbname);
-	    db_close_database_shutdown_driver(to_driver);
-	    if (from_driver != to_driver)
-		db_close_database_shutdown_driver(from_driver);
-
-	    return DB_FAILED;
+	    if (G_get_overwrite()) {
+		G_warning(_("Table <%s> already exists in database and will be overwritten"),
+			  to_tblname);
+		ret = db_drop_table(from_driver, &tblnames[i]);
+	    }
+	    else {
+		G_warning(_("Table <%s> already exists in database <%s>"),
+			  to_tblname, to_dbname);
+	    }
+	    
+	    if (ret != DB_OK) {
+		db_close_database_shutdown_driver(to_driver);
+		if (from_driver != to_driver)
+		    db_close_database_shutdown_driver(from_driver);
+		
+		return DB_FAILED;
+	    }
 	}
     }
 

Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2011-07-05 10:16:45 UTC (rev 46984)
+++ grass/trunk/lib/init/grass.py	2011-07-05 10:18:09 UTC (rev 46985)
@@ -72,6 +72,15 @@
     except:
 	pass
 
+def clean_env():
+    env_curr = read_gisrc()
+    env_new  = {}
+    for k,v in env_curr.iteritems():
+        if 'MONITOR' not in k:
+            env_new[k] = v
+    
+    write_gisrc(env_new)
+
 def cleanup_dir(path):
     if not path:
 	return
@@ -1044,6 +1053,7 @@
 
 clear_screen()
 
+clean_env()
 clean_temp()
 
 try_remove(lockfile)



More information about the grass-commit mailing list