[GRASS-SVN] r43088 - grass/trunk/scripts/g.extension
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 13 06:17:12 EDT 2010
Author: martinl
Date: 2010-08-13 10:17:12 +0000 (Fri, 13 Aug 2010)
New Revision: 43088
Modified:
grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: fix remove option when module is not available
add new flag to avoid removing downloaded source code
Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py 2010-08-13 08:22:39 UTC (rev 43087)
+++ grass/trunk/scripts/g.extension/g.extension.py 2010-08-13 10:17:12 UTC (rev 43088)
@@ -79,6 +79,10 @@
#% description: List available modules in the add-ons repository in shell script style
#% guisection: Print
#%end
+#%flag
+#% key: d
+#% description: Don't deleted downloaded source code when installing new extension
+#%end
import os
import sys
@@ -90,6 +94,7 @@
from grass.script import core as grass
# temp dir
+remove_tmpdir = True
tmpdir = grass.tempfile()
grass.try_remove(tmpdir)
os.mkdir(tmpdir)
@@ -241,9 +246,12 @@
return ret
def cleanup():
- global tmpdir
- grass.try_rmdir(tmpdir)
-
+ global tmpdir, remove_tmpdir
+ if remove_tmpdir:
+ grass.try_rmdir(tmpdir)
+ else:
+ grass.info(_("Path to the source code: '%s'") % tmpdir)
+
def install_extension(svnurl, prefix, module):
gisbase = os.getenv('GISBASE')
if not gisbase:
@@ -295,8 +303,8 @@
def remove_extension(prefix, module):
# is module available?
- if not grass.find_program(module):
- grass.fatal(_("'%s' not found") % module)
+ if not os.path.exists(os.path.join(prefix, 'bin', module)):
+ grass.fatal(_("Module '%s' not found") % module)
for file in [os.path.join(prefix, 'bin', module),
os.path.join(prefix, 'scripts', module),
@@ -337,6 +345,13 @@
grass.warning(_("'%s' created") % options['prefix'])
+ if flags['d']:
+ if options['operation'] != 'add':
+ grass.warning(_("Flag 'd' is relevant only to 'operation=add'. Ignoring this flag."))
+ else:
+ global remove_tmpdir
+ remove_tmpdir = False
+
if options['operation'] == 'add':
install_extension(options['svnurl'], options['prefix'], options['extension'])
else: # remove
More information about the grass-commit
mailing list