[GRASS-SVN] r38345 - grass-addons/vector/v.krige

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 10 08:03:51 EDT 2009


Author: aghisla
Date: 2009-07-10 08:03:51 -0400 (Fri, 10 Jul 2009)
New Revision: 38345

Modified:
   grass-addons/vector/v.krige/v.krige.py
Log:
dependency check at the beginning of the script


Modified: grass-addons/vector/v.krige/v.krige.py
===================================================================
--- grass-addons/vector/v.krige/v.krige.py	2009-07-10 11:29:59 UTC (rev 38344)
+++ grass-addons/vector/v.krige/v.krige.py	2009-07-10 12:03:51 UTC (rev 38345)
@@ -84,14 +84,35 @@
 
 import os, sys
 
+########### depenedency check
+# GRASS binding
 try:
+    import grass.script as grass
+except ImportError:
+    sys.exit(_("No GRASS-python library found."))
+
+# R
+try: 
+    grass.find_program('R')
+except:
+    sys.exit(_("R is not installed. Install it and re-run, or modify environment variables."))
+
+# rpy2
+try:
     import rpy2.robjects as robjects
     haveRpy2 = True
 except ImportError:
-    print >> sys.stderr, "Rpy2 not found. Please install it and re-run."
+    print >> sys.stderr, "Rpy2 not found. Please install it and re-run." # ok for other OSes?
     haveRpy2 = False
+if not haveRpy2:
+    sys.exit(1)
 
-import grass.script as grass 
+# R packages gstat or geoR
+try:
+    robjects.r.require("gstat") or robjects.r.require("geoR")
+except:
+    sys.exit(_("No gstat neither geoR package installed. Install one of them (gstat preferably) via R installer."))
+###########
 
 GUIModulesPath = os.path.join(os.getenv("GISBASE"), "etc", "wxpython", "gui_modules")
 sys.path.append(GUIModulesPath)
@@ -439,9 +460,7 @@
     # popup windows for missing stuff messages.
     # For the moment, deps are checked when creating the notebook pages for each package, and the
     # data availability when clicking Run button. Quite late.
-    if not haveRpy2:
-        sys.exit(1)
-
+    
     #@FIXME: solve this double ifelse. the control should not be done twice.
     if argv is None:
         argv = sys.argv[1:] #stripping first item, the full name of this script
@@ -477,8 +496,7 @@
             except ImportError, e:
                 grass.fatal(_("R package automap is missing, no variogram autofit available."))
         
-        controller = Controller()
-        
+        controller = Controller()    
         controller.Run(input = options['input'],
                        column = options['column'],
                        output = options['output'],



More information about the grass-commit mailing list