Explorar o código

i.landsat.rgb: write history only for raster maps in the current mapset

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34935 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa %!s(int64=16) %!d(string=hai) anos
pai
achega
dd476fc559
Modificáronse 2 ficheiros con 14 adicións e 5 borrados
  1. 11 2
      lib/python/grass.py
  2. 3 3
      scripts/i.landsat.rgb/i.landsat.rgb.py

+ 11 - 2
lib/python/grass.py

@@ -519,9 +519,18 @@ def vector_history(map):
 def raster_history(map):
     """Set the command history for a raster map to the command used to
     invoke the script (interface to `r.support').
-    """
-    run_command('r.support', map = map, history = os.environ['CMDLINE'])
 
+    @return 1 on success
+    @return 0 on failure
+    """
+    current_mapset = gisenv()['MAPSET']
+    if find_file(name = map)['mapset'] == current_mapset:
+        run_command('r.support', map = map, history = os.environ['CMDLINE'])
+        return 1
+    
+    warning("Unable to write history for <%s>. Raster map <%s> not found in current mapset." % (map, map))
+    return 0
+    
 # run "r.info -rgstmpud ..." and parse output
 
 def raster_info(map):

+ 3 - 3
scripts/i.landsat.rgb/i.landsat.rgb.py

@@ -21,7 +21,7 @@
 #############################################################################
 
 #%Module
-#%  description: Auto-balancing of colors for LANDSAT images
+#%  description: Performs auto-balancing of colors for LANDSAT images.
 #%  keywords: raster, imagery, colors
 #%End
 #%option
@@ -111,7 +111,7 @@ def main():
 
     if not preserve:
 	for i in [red, green, blue]:
-	    grass.message("Processing <%s> ..." % i)
+	    grass.message("Processing <%s>..." % i)
 	    v0 = get_percentile(i, 2)
 	    v1 = get_percentile(i, brightness)
 	    grass.debug("<%s>:  min=%f   max=%f" % (i, v0, v1))
@@ -120,7 +120,7 @@ def main():
 	all_max = 0
 	all_min = 255
 	for i in [red, green, blue]:
-	    grass.message("Processing <%s> ..." % i)
+	    grass.message("Processing <%s>..." % i)
 	    v0 = get_percentile(i, 2)
 	    v1 = get_percentile(i, brightness)
 	    grass.debug("<%s>:  min=%f   max=%f" % (i, v0, v1))