[GRASS-SVN] r48895 - in grass-addons/grass7/raster/r.modis: r.modis.download r.modis.import

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 21 05:51:26 EDT 2011


Author: lucadelu
Date: 2011-10-21 02:51:26 -0700 (Fri, 21 Oct 2011)
New Revision: 48895

Modified:
   grass-addons/grass7/raster/r.modis/r.modis.download/r.modis.download.py
   grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py
Log:
add check to search library in GISBASE or in GRASS_ADDONS_PATH

Modified: grass-addons/grass7/raster/r.modis/r.modis.download/r.modis.download.py
===================================================================
--- grass-addons/grass7/raster/r.modis/r.modis.download/r.modis.download.py	2011-10-21 09:26:30 UTC (rev 48894)
+++ grass-addons/grass7/raster/r.modis/r.modis.download/r.modis.download.py	2011-10-21 09:51:26 UTC (rev 48895)
@@ -82,8 +82,13 @@
 import grass.script as grass
 
 # add the folder containing libraries to python path
-libmodis = os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')
-sys.path.append(libmodis)
+if os.path.isdir(os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')):
+    libmodis = os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')
+elif os.path.isdir(os.path.join(os.getenv('GRASS_ADDON_PATH'), 'etc', 'r.modis')):
+    libmodis = os.path.join(os.getenv('GRASS_ADDON_PATH'), 'etc', 'r.modis')
+else:
+    print "ERROR: path to libraries not found"
+    sys.exit()
 # try to import pymodis (modis) and some class for r.modis.download
 try:
     from rmodislib import product

Modified: grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py
===================================================================
--- grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py	2011-10-21 09:26:30 UTC (rev 48894)
+++ grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py	2011-10-21 09:51:26 UTC (rev 48895)
@@ -90,8 +90,17 @@
 import os, sys, string, glob, shutil
 import grass.script as grass
 from datetime import date
+
+
 # add the folder containing libraries to python path
-libmodis = os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')
+if os.path.isdir(os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')):
+    libmodis = os.path.join(os.getenv('GISBASE'), 'etc', 'r.modis')
+elif os.path.isdir(os.path.join(os.getenv('GRASS_ADDON_PATH'), 'etc', 'r.modis')):
+    libmodis = os.path.join(os.getenv('GRASS_ADDON_PATH'), 'etc', 'r.modis')
+else:
+    print "ERROR: path to libraries not found"
+    sys.exit()
+
 sys.path.append(libmodis)
 # try to import pymodis (modis) and some classes for r.modis.download
 try:



More information about the grass-commit mailing list