[GRASS-SVN] r53396 - in grass/trunk: lib/python lib/python/temporal temporal/t.vect.db.select temporal/t.vect.list

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 15 06:26:33 PDT 2012


Author: huhabla
Date: 2012-10-15 06:26:32 -0700 (Mon, 15 Oct 2012)
New Revision: 53396

Modified:
   grass/trunk/lib/python/core.py
   grass/trunk/lib/python/temporal/space_time_datasets_tools.py
   grass/trunk/lib/python/temporal/stds_import.py
   grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py
   grass/trunk/temporal/t.vect.list/test.t.vect.list.layer.sh
   grass/trunk/temporal/t.vect.list/test.t.vect.list.sh
Log:
Moved raise_on_error to fatal(). Modified dependent python modules.
Updated tests and bugfixing of the temporal GIS framework.


Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2012-10-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/lib/python/core.py	2012-10-15 13:26:32 UTC (rev 53396)
@@ -367,36 +367,37 @@
 
 def error(msg):
     """!Display an error message using `g.message -e`
-
-    Raise exception when on_error is 'raise'.
     
     @param msg error message to be displayed
     """
-    global raise_on_error
-    if raise_on_error:
-        raise ScriptError(msg)
-    else:
-        message(msg, flag = 'e')
+    message(msg, flag = 'e')
 
 def fatal(msg):
     """!Display an error message using `g.message -e`, then abort
     
+    Raise exception when raise_on_error is 'True'.
+    
     @param msg error message to be displayed
     """
+    global raise_on_error
+    if raise_on_error:
+        raise ScriptError(msg)
+    
     error(msg)
     sys.exit(1)
     
 def set_raise_on_error(raise_exp = True):
-    """!Define behaviour on error (error() called)
+    """!Define behaviour on fatal error (fatal() called)
 
     @param raise_exp True to raise ScriptError instead of calling
-    error()
+    sys.exit(1) in fatal()
     
     @return current status
     """
     global raise_on_error
     tmp_raise = raise_on_error
     raise_on_error = raise_exp
+    return tmp_raise
 
 # interface to g.parser
 

Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-10-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-10-15 13:26:32 UTC (rev 53396)
@@ -222,9 +222,9 @@
             if not core.overwrite():                        
                 if map.get_layer():
                     core.warning(_("Map is already registered in temporal database. "
-                                   "Unable to update %s map <%s> with layer %i. "
+                                   "Unable to update %s map <%s> with layer %s. "
                                    "Overwrite flag is not set.") %
-                               (map.get_type(), map.get_map_id(), map.get_layer()))
+                               (map.get_type(), map.get_map_id(), str(map.get_layer())))
                 else:
                     core.warning(_("Map is already registered in temporal database. "
                                    "Unable to update %s map <%s>. "

Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py	2012-10-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/lib/python/temporal/stds_import.py	2012-10-15 13:26:32 UTC (rev 53396)
@@ -170,6 +170,8 @@
                           should be imported
     """
 
+    global raise_on_error
+    old_state = core.raise_on_error
     core.set_raise_on_error(True)
 
     # Check if input file and extraction directory exits
@@ -393,3 +395,5 @@
             ret = core.run_command("g.mapset", mapset=old_env["MAPSET"],
                                    location=old_env["LOCATION_NAME"],
                                    gisdbase=old_env["GISDBASE"])
+        
+        core.set_raise_on_error(old_state)

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-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py	2012-10-15 13:26:32 UTC (rev 53396)
@@ -102,7 +102,7 @@
 
             select = grass.read_command("v.db.select", map=vector_name, 
                                         layer=layer, columns=columns, 
-                                        fs="%s" % (fs), where=where)
+                                        separator="%s" % (fs), where=where)
 
             if not select:
                 grass.fatal(_("Unable to run v.db.select for vector map <%s> "

Modified: grass/trunk/temporal/t.vect.list/test.t.vect.list.layer.sh
===================================================================
--- grass/trunk/temporal/t.vect.list/test.t.vect.list.layer.sh	2012-10-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/temporal/t.vect.list/test.t.vect.list.layer.sh	2012-10-15 13:26:32 UTC (rev 53396)
@@ -85,31 +85,31 @@
 t.create --o type=stvds temporaltype=absolute output=soils_abs5 title="A test with input files" descr="A test with input files"
 
 # The first @test
-t.register type=vect    input=soils_abs1 file="${n1}" start="2001-01-01" increment="1 months"
+t.register type=vect --o   input=soils_abs1 file="${n1}" start="2001-01-01" increment="1 months"
 t.vect.list    fs=" | " method=comma     input=soils_abs1
 t.vect.list -h input=soils_abs1
 t.vect.list -h fs=" | " method=cols      input=soils_abs1
 t.vect.list -h fs=" | " method=delta     input=soils_abs1
 t.vect.list -h fs=" | " method=deltagaps input=soils_abs1
 
-t.register type=vect -i input=soils_abs2 file="${n2}"
+t.register type=vect --o -i input=soils_abs2 file="${n2}"
 t.vect.list    fs=" | " method=comma     input=soils_abs2
 t.vect.list -h input=soils_abs2
 t.vect.list -h fs=" | " method=cols      input=soils_abs2
 t.vect.list -h fs=" | " method=delta     input=soils_abs2
 t.vect.list -h fs=" | " method=deltagaps input=soils_abs2
 
-t.register type=vect -i input=soils_abs3 file="${n3}"
+t.register type=vect --o -i input=soils_abs3 file="${n3}"
 t.vect.list    fs=" | " method=comma     input=soils_abs3
 t.vect.list -h fs=" | " method=delta     input=soils_abs3
 t.vect.list -h fs=" | " method=deltagaps input=soils_abs3
 
-t.register type=vect -i input=soils_abs4 file="${n4}"
+t.register type=vect --o -i input=soils_abs4 file="${n4}"
 t.vect.list    fs=" | " method=comma     input=soils_abs4
 t.vect.list -h fs=" | " method=delta     input=soils_abs4
 t.vect.list -h fs=" | " method=deltagaps input=soils_abs4
 
-t.register type=vect -i input=soils_abs5 file="${n5}"
+t.register type=vect --o -i input=soils_abs5 file="${n5}"
 t.vect.list    fs=" | " method=comma     input=soils_abs5
 t.vect.list -h input=soils_abs5
 t.vect.list -h fs=" | " method=cols      input=soils_abs5

Modified: grass/trunk/temporal/t.vect.list/test.t.vect.list.sh
===================================================================
--- grass/trunk/temporal/t.vect.list/test.t.vect.list.sh	2012-10-15 13:19:18 UTC (rev 53395)
+++ grass/trunk/temporal/t.vect.list/test.t.vect.list.sh	2012-10-15 13:26:32 UTC (rev 53396)
@@ -71,31 +71,31 @@
 t.create --o type=stvds temporaltype=absolute output=lidar_abs5 title="A test with input files" descr="A test with input files"
 
 # The first @test
-t.register type=vect  input=lidar_abs1 file="${n1}" start="2001-01-01" increment="1 months"
+t.register --o type=vect  input=lidar_abs1 file="${n1}" start="2001-01-01" increment="1 months"
 t.vect.list    fs=" | " method=comma     input=lidar_abs1
 t.vect.list -h input=lidar_abs1
 t.vect.list -h fs=" | " method=cols      input=lidar_abs1
 t.vect.list -h fs=" | " method=delta     input=lidar_abs1
 t.vect.list -h fs=" | " method=deltagaps input=lidar_abs1
 
-t.register type=vect -i input=lidar_abs2 file="${n2}"
+t.register --o type=vect -i input=lidar_abs2 file="${n2}"
 t.vect.list    fs=" | " method=comma     input=lidar_abs2
 t.vect.list -h input=lidar_abs2
 t.vect.list -h fs=" | " method=cols      input=lidar_abs2
 t.vect.list -h fs=" | " method=delta     input=lidar_abs2
 t.vect.list -h fs=" | " method=deltagaps input=lidar_abs2
 
-t.register type=vect -i input=lidar_abs3 file="${n3}"
+t.register --o type=vect -i input=lidar_abs3 file="${n3}"
 t.vect.list    fs=" | " method=comma     input=lidar_abs3
 t.vect.list -h fs=" | " method=delta     input=lidar_abs3
 t.vect.list -h fs=" | " method=deltagaps input=lidar_abs3
 
-t.register type=vect -i input=lidar_abs4 file="${n4}"
+t.register --o type=vect -i input=lidar_abs4 file="${n4}"
 t.vect.list    fs=" | " method=comma     input=lidar_abs4
 t.vect.list -h fs=" | " method=delta     input=lidar_abs4
 t.vect.list -h fs=" | " method=deltagaps input=lidar_abs4
 
-t.register type=vect -i input=lidar_abs5 file="${n5}"
+t.register --o type=vect -i input=lidar_abs5 file="${n5}"
 t.vect.list    fs=" | " method=comma     input=lidar_abs5
 t.vect.list -h input=lidar_abs5
 t.vect.list -h fs=" | " method=cols      input=lidar_abs5
@@ -104,4 +104,4 @@
 
 t.unregister type=vect maps=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6
 t.remove type=stvds input=lidar_abs1,lidar_abs2,lidar_abs3,lidar_abs4,lidar_abs5
-g.remove vect=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6
\ No newline at end of file
+g.remove vect=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6



More information about the grass-commit mailing list