[GRASS-SVN] r70142 - grass/branches/releasebranch_7_2/scripts/d.correlate

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 27 03:43:56 PST 2016


Author: martinl
Date: 2016-12-27 03:43:56 -0800 (Tue, 27 Dec 2016)
New Revision: 70142

Modified:
   grass/branches/releasebranch_7_2/scripts/d.correlate/d.correlate.py
Log:
d.correlate: catch exceptions cause by d.text (no monitor) (relbr72: merge r70141 from trunk)

Modified: grass/branches/releasebranch_7_2/scripts/d.correlate/d.correlate.py
===================================================================
--- grass/branches/releasebranch_7_2/scripts/d.correlate/d.correlate.py	2016-12-27 11:42:51 UTC (rev 70141)
+++ grass/branches/releasebranch_7_2/scripts/d.correlate/d.correlate.py	2016-12-27 11:43:56 UTC (rev 70142)
@@ -30,8 +30,8 @@
 import os
 from grass.script.utils import try_remove
 from grass.script import core as gcore
+from grass.exceptions import CalledModuleError
 
-
 def main():
     layers = options['map'].split(',')
 
@@ -44,9 +44,12 @@
         if not gcore.find_file(map, element='cell')['file']:
             gcore.fatal(_("Raster map <%s> not found") % map)
 
-    gcore.write_command('d.text', color='black', size=4, line=1,
-                        stdin="CORRELATION")
-
+    try:
+        gcore.write_command('d.text', color='black', size=4, line=1,
+                            stdin="CORRELATION")
+    except CalledModuleError:
+        return 1
+    
     os.environ['GRASS_RENDER_FILE_READ'] = 'TRUE'
 
     colors = "red black blue green gray violet".split()
@@ -108,6 +111,8 @@
 
     try_remove(tmpfile)
 
+    return 0
+
 if __name__ == "__main__":
     options, flags = gcore.parser()
-    main()
+    sys.exit(main())



More information about the grass-commit mailing list