[GRASS-SVN] r65389 - grass/trunk/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jun 6 08:58:45 PDT 2015


Author: martinl
Date: 2015-06-06 08:58:45 -0700 (Sat, 06 Jun 2015)
New Revision: 65389

Modified:
   grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: check if target directory is writable

Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2015-06-06 14:31:06 UTC (rev 65388)
+++ grass/trunk/scripts/g.extension/g.extension.py	2015-06-06 15:58:45 UTC (rev 65389)
@@ -1034,6 +1034,7 @@
     # define path
     if flags['s']:
         options['prefix'] = os.environ['GISBASE']
+    
     if options['prefix'] == '$GRASS_ADDON_BASE':
         if not os.getenv('GRASS_ADDON_BASE'):
             grass.warning(_("GRASS_ADDON_BASE is not defined, "
@@ -1041,6 +1042,12 @@
             options['prefix'] = os.path.join(os.environ['HOME'], '.grass%s' % version[0], 'addons')
         else:
             options['prefix'] = os.environ['GRASS_ADDON_BASE']
+
+    if not os.access(options['prefix'], os.W_OK):
+        grass.fatal(_("You don't have permission to install extension to <{}>. "
+                      "Try to run {} as administrator "
+                      "(or as sudo).").format(options['prefix'], 'g.extension'))
+
     if 'svn.osgeo.org/grass/grass-addons/grass7' in options['svnurl']:
         # use pregenerated modules XML file
         xmlurl = "http://grass.osgeo.org/addons/grass%s" % version[0]



More information about the grass-commit mailing list