[GRASS-SVN] r49904 - in grass/trunk: gui/wxpython/core
gui/wxpython/gui_core gui/wxpython/modules lib/init
macosx/app scripts/g.extension scripts/g.manual
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 25 16:30:56 EST 2011
Author: martinl
Date: 2011-12-25 13:30:56 -0800 (Sun, 25 Dec 2011)
New Revision: 49904
Modified:
grass/trunk/gui/wxpython/core/globalvar.py
grass/trunk/gui/wxpython/gui_core/forms.py
grass/trunk/gui/wxpython/modules/extensions.py
grass/trunk/lib/init/grass.py
grass/trunk/lib/init/variables.html
grass/trunk/macosx/app/grass.sh.in
grass/trunk/scripts/g.extension/g.extension.py
grass/trunk/scripts/g.manual/g.manual.py
Log:
define GRASS_ADDON_BASE
Modified: grass/trunk/gui/wxpython/core/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/core/globalvar.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/gui/wxpython/core/globalvar.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -143,20 +143,20 @@
os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
cmd = cmd + os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts'))
- # scan addons
- if os.getenv('GRASS_ADDON_PATH'):
- path = os.getenv('GRASS_ADDON_PATH')
- bpath = os.path.join(path, 'bin')
- spath = os.path.join(path, 'scripts')
- if not scriptsOnly and os.path.exists(bpath) and \
- os.path.isdir(bpath):
- for fname in os.listdir(bpath):
- name, ext = os.path.splitext(fname)
- if not EXT_BIN:
- cmd.append(fname)
- elif ext == EXT_BIN:
- cmd.append(name)
+ # scan addons (base)
+ if os.getenv('GRASS_ADDON_BASE'):
+ for path in os.getenv('GRASS_ADDON_BASE').split(os.pathsep):
+ bpath = os.path.join(path, 'bin')
+ if not scriptsOnly and os.path.exists(bpath) and \
+ os.path.isdir(bpath):
+ for fname in os.listdir(bpath):
+ name, ext = os.path.splitext(fname)
+ if not EXT_BIN:
+ cmd.append(fname)
+ elif ext == EXT_BIN:
+ cmd.append(name)
+ spath = os.path.join(path, 'scripts')
if os.path.exists(spath) and os.path.isdir(spath):
for fname in os.listdir(spath):
name, ext = os.path.splitext(fname)
@@ -164,6 +164,16 @@
cmd.append(fname)
elif ext == EXT_SCT:
cmd.append(name)
+
+ # scan addons (path)
+ if os.getenv('GRASS_ADDON_PATH'):
+ for path in os.getenv('GRASS_ADDON_PATH').split(os.pathsep):
+ for fname in os.listdir(path):
+ name, ext = os.path.splitext(fname)
+ if ext in [EXT_BIN, EXT_SCT]:
+ cmd.append(name)
+ else:
+ cmd.append(fname)
return cmd
Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/gui/wxpython/gui_core/forms.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -2101,7 +2101,8 @@
def OnInit(self):
msg = self.grass_task.get_error_msg()
if msg:
- gcmd.GError(msg + '\n\nTry to set up GRASS_ADDON_PATH variable.')
+ gcmd.GError(msg + '\n\n' +
+ _('Try to set up GRASS_ADDON_PATH or GRASS_ADDON_BASE variable.'))
return True
self.mf = TaskFrame(parent = None, task_description = self.grass_task)
Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/gui/wxpython/modules/extensions.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -222,7 +222,7 @@
item = self.tree.GetSelected()
if not item or not item.IsOk() or \
returncode != 0 or \
- not os.getenv('GRASS_ADDON_PATH'):
+ not os.getenv('GRASS_ADDON_BASE'):
return
name = self.tree.GetItemText(item)
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/lib/init/grass.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -167,6 +167,7 @@
GRASS_WISH %s
GRASS_HTML_BROWSER %s
GRASS_ADDON_PATH %s
+ GRASS_ADDON_BASE %s
GRASS_BATCH_JOB %s
GRASS_PYTHON %s
""" % (_("Usage"),
@@ -189,7 +190,8 @@
_("select GUI (text, gui)"),
_("set wish shell name to override 'wish'"),
_("set html web browser for help pages"),
- _("set additional path(s) to local GRASS modules"),
+ _("set additional path(s) to local GRASS modules or user scripts"),
+ _("set additional GISBASE for locally installed GRASS Addons"),
_("shell script to be processed as batch job"),
_("set python shell name to override 'python'"))
@@ -284,7 +286,7 @@
# FIXME oldtcltk, gis.m, d.m no longer exist
if grass_gui in ['d.m', 'gis.m', 'oldtcltk', 'tcltk']:
- warning(_("GUI '%s' not supported in this version") % grass_gui)
+ warning(_("GUI <%s> not supported in this version") % grass_gui)
grass_gui = default_gui
def get_locale():
@@ -329,16 +331,22 @@
os.environ[var] = path
def set_paths():
+ # addons (path)
addon_path = os.getenv('GRASS_ADDON_PATH')
- if not addon_path:
- addon_path = os.path.join(grass_config_dir, 'addons')
- os.environ['GRASS_ADDON_PATH'] = addon_path
- # message(_("GRASS_ADDON_PATH undefined, using '%s'") % addon_path)
+ if addon_path:
+ for path in addons_path.split(os.pathsep):
+ path_prepend(addon_path, 'PATH')
- path_prepend(addon_path, 'PATH')
- path_prepend(os.path.join(addon_path, 'scripts'), 'PATH')
- path_prepend(os.path.join(addon_path, 'bin'), 'PATH')
+ # addons (base)
+ addon_base = os.getenv('GRASS_ADDON_BASE')
+ if not addon_base:
+ addon_base = os.path.join(grass_config_dir, 'addons')
+ os.environ['GRASS_ADDON_BASE'] = addon_base
+ for path in addon_base.split(os.pathsep):
+ path_prepend(os.path.join(path, 'scripts'), 'PATH')
+ path_prepend(os.path.join(path, 'bin'), 'PATH')
+ # standard installation
path_prepend(gfile('scripts'), 'PATH')
path_prepend(gfile('bin'), 'PATH')
@@ -708,7 +716,7 @@
def start_gui():
# Start the chosen GUI but ignore text
if grass_debug:
- message(_("GRASS GUI should be '%s'") % grass_gui)
+ message(_("GRASS GUI should be <%s>") % grass_gui)
# Check for gui interface
if grass_gui == "wxpython":
@@ -1132,7 +1140,7 @@
say_hello()
show_info()
if grass_gui == "wxpython":
- message(_("Launching '%s' GUI in the background, please wait...") % grass_gui)
+ message(_("Launching <%s> GUI in the background, please wait...") % grass_gui)
if sh in ['csh', 'tcsh']:
csh_startup()
Modified: grass/trunk/lib/init/variables.html
===================================================================
--- grass/trunk/lib/init/variables.html 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/lib/init/variables.html 2011-12-25 21:30:56 UTC (rev 49904)
@@ -100,8 +100,16 @@
<dt>GRASS_ADDON_PATH</dt>
<dd>[grass startup script]<br> allows to specify additional paths to
- local GRASS modules extra to standard distribution. The default on
- GNU/Linux is <tt>$HOME/.grass7/addons</tt>.</dd>
+ local GRASS modules or user scripts extra to standard GRASS
+ distribution.</dd>
+
+ <dt>GRASS_ADDON_BASE</dt>
+ <dd>[grass startup script]<br> allows to specify additional GISBASE
+ for local GRASS modules (normally installed as GRASS Addons
+ by <tt>g.extension</tt> module) extra to standard
+ distribution. The default on GNU/Linux
+ is <tt>$HOME/.grass7/addons</tt>, on MS
+ Windows <tt>$APPDATA\GRASS7\addons</tt>.</dd>
<dt>GRASS_ADDON_ETC</dt>
<dd>[libgis, g.findetc]<br>
Modified: grass/trunk/macosx/app/grass.sh.in
===================================================================
--- grass/trunk/macosx/app/grass.sh.in 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/macosx/app/grass.sh.in 2011-12-25 21:30:56 UTC (rev 49904)
@@ -46,12 +46,12 @@
# add some OS X style app support paths, and create user one if missing.
mkdir -p "$GISBASE_USER/Modules/bin"
-if [ "$GRASS_ADDON_PATH" ] ; then
- GRASS_ADDON_PATH="$GRASS_ADDON_PATH:$GISBASE_USER/Modules:$GISBASE_SYSTEM/Modules"
+if [ "$GRASS_ADDON_BASE" ] ; then
+ GRASS_ADDON_BASE="$GRASS_ADDON_BASE:$GISBASE_USER/Modules:$GISBASE_SYSTEM/Modules"
else
- GRASS_ADDON_PATH="$GISBASE_USER/Modules:$GISBASE_SYSTEM/Modules"
+ GRASS_ADDON_BASE="$GISBASE_USER/Modules:$GISBASE_SYSTEM/Modules"
fi
-export GRASS_ADDON_PATH
+export GRASS_ADDON_BASE
mkdir -p "$GISBASE_USER/Modules/etc"
if [ "$GRASS_ADDON_ETC" ] ; then
Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/scripts/g.extension/g.extension.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -52,7 +52,7 @@
#% type: string
#% key_desc: path
#% description: Prefix where to install extension (ignored when flag -s is given)
-#% answer: $GRASS_ADDON_PATH
+#% answer: $GRASS_ADDON_BASE
#% required: no
#%end
@@ -468,10 +468,9 @@
install_extension_xml()
grass.message(_("Installation of <%s> successfully finished") % options['extension'])
- if not os.environ.has_key('GRASS_ADDON_PATH') or \
- not os.environ['GRASS_ADDON_PATH']:
+ if not os.getenv('GRASS_ADDON_BASE'):
grass.warning(_('This add-on module will not function until you set the '
- 'GRASS_ADDON_PATH environment variable (see "g.manual variables")'))
+ 'GRASS_ADDON_BASE environment variable (see "g.manual variables")'))
# install extension on other plaforms
def install_extension_other():
@@ -686,19 +685,18 @@
# define path
if flags['s']:
options['prefix'] = os.environ['GISBASE']
- if options['prefix'] == '$GRASS_ADDON_PATH':
- if not os.environ.has_key('GRASS_ADDON_PATH') or \
- not os.environ['GRASS_ADDON_PATH']:
+ if options['prefix'] == '$GRASS_ADDON_BASE':
+ if not os.getenv('GRASS_ADDON_BASE'):
major_version = int(grass.version()['version'].split('.', 1)[0])
- grass.warning(_("GRASS_ADDON_PATH is not defined, "
- "installing to ~/.grass%d/addons/") % major_version)
+ grass.warning(_("GRASS_ADDON_BASE is not defined, "
+ "installing to ~/.grass%d/addons") % major_version)
options['prefix'] = os.path.join(os.environ['HOME'], '.grass%d' % major_version, 'addons')
else:
- path_list = os.environ['GRASS_ADDON_PATH'].split(os.pathsep)
+ path_list = os.environ['GRASS_ADDON_BASE'].split(os.pathsep)
if len(path_list) < 1:
- grass.fatal(_("Invalid GRASS_ADDON_PATH value - '%s'") % os.environ['GRASS_ADDON_PATH'])
+ grass.fatal(_("Invalid GRASS_ADDON_BASE value - '%s'") % os.environ['GRASS_ADDON_BASE'])
if len(path_list) > 1:
- grass.warning(_("GRASS_ADDON_PATH has more items, using first defined - '%s'") % path_list[0])
+ grass.warning(_("GRASS_ADDON_BASE has more items, using first defined - '%s'") % path_list[0])
options['prefix'] = path_list[0]
# list available extensions
Modified: grass/trunk/scripts/g.manual/g.manual.py
===================================================================
--- grass/trunk/scripts/g.manual/g.manual.py 2011-12-25 21:28:55 UTC (rev 49903)
+++ grass/trunk/scripts/g.manual/g.manual.py 2011-12-25 21:30:56 UTC (rev 49904)
@@ -45,8 +45,11 @@
grass.fatal(_("Browser <%s> not found") % browser)
path = os.path.join(gisbase, 'docs', 'html', entry + '.html')
- if not os.path.exists(path) and os.getenv('GRASS_ADDON_PATH'):
- path = os.path.join(os.getenv('GRASS_ADDON_PATH'), 'docs', 'html', entry + '.html')
+ if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'):
+ for apath in os.getenv('GRASS_ADDON_BASE').split(os.pathsep):
+ path = os.path.join(apath, 'docs', 'html', entry + '.html')
+ if os.path.exists(path):
+ break
if not os.path.exists(path):
grass.fatal(_("No HTML manual page entry for <%s>") % entry)
More information about the grass-commit
mailing list