[GRASS-SVN] r53467 - in grass/trunk/gui/wxpython: core gui_core modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 18 08:02:01 PDT 2012
Author: martinl
Date: 2012-10-18 08:02:00 -0700 (Thu, 18 Oct 2012)
New Revision: 53467
Modified:
grass/trunk/gui/wxpython/core/globalvar.py
grass/trunk/gui/wxpython/gui_core/goutput.py
grass/trunk/gui/wxpython/modules/extensions.py
Log:
wxGUI: update prompt when new addon is installed
Modified: grass/trunk/gui/wxpython/core/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/core/globalvar.py 2012-10-18 11:50:40 UTC (rev 53466)
+++ grass/trunk/gui/wxpython/core/globalvar.py 2012-10-18 15:02:00 UTC (rev 53467)
@@ -25,6 +25,8 @@
ETCIMGDIR = os.path.join(ETCDIR, "gui", "images")
ETCSYMBOLDIR = os.path.join(ETCDIR, "gui", "images", "symbols")
+from core.debug import Debug
+
sys.path.append(os.path.join(ETCDIR, "python"))
import grass.script as grass
@@ -146,47 +148,46 @@
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 (base)
- addons_base = os.getenv('GRASS_ADDON_BASE')
- if addons_base and os.path.exists(addons_base) \
- and not os.path.isdir(addons_base):
- bpath = os.path.join(addons_base, '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(addons_base, 'scripts')
- if os.path.exists(spath) and os.path.isdir(spath):
- for fname in os.listdir(spath):
- name, ext = os.path.splitext(fname)
- if not EXT_SCT:
- cmd.append(fname)
- elif ext == EXT_SCT:
- cmd.append(name)
+ return set(cmd), scripts
+
+def UpdateGRASSAddOnCommands():
+ """!Update list of available GRASS AddOns commands to use when
+ parsing string from the command line
+ """
+ global grassCmd, grassScripts
# scan addons (path)
- if os.getenv('GRASS_ADDON_PATH'):
- for path in os.getenv('GRASS_ADDON_PATH').split(os.pathsep):
- if not os.path.exists(path) or not os.path.isdir(path):
- continue
- for fname in os.listdir(path):
- if scripts: # win32
- name, ext = os.path.splitext(fname)
- cmd.append(name)
- if ext in scripts.keys():
- scripts[ext].append(name)
- else:
- cmd.append(fname)
+ addonPath = os.getenv('GRASS_ADDON_PATH', '')
+ addonBase = os.getenv('GRASS_ADDON_BASE')
+ if addonBase:
+ addonPath += os.pathsep + os.path.join(addonBase, 'bin') + os.pathsep + \
+ os.path.join(addonBase, 'scripts')
- return set(cmd), scripts
+ nCmd = 0
+ for path in addonPath.split(os.pathsep):
+ if not os.path.exists(path) or not os.path.isdir(path):
+ continue
+ for fname in os.listdir(path):
+ if grassScripts: # win32
+ name, ext = os.path.splitext(fname)
+ if name not in grassCmd:
+ grassCmd.add(name)
+ nCmd += 1
+ if ext in grassScripts.keys() and \
+ name not in grassScripts[ext]:
+ grassScripts[ext].append(name)
+ nCmd += 1
+ else:
+ if fname not in grassCmd:
+ grassCmd.add(fname)
+ nCmd += 1
+
+ Debug.msg(1, "Number of new AddOn commands: %d", nCmd)
"""@brief Collected GRASS-relared binaries/scripts"""
grassCmd, grassScripts = GetGRASSCommands()
+Debug.msg(1, "Number of GRASS commands: %d", len(grassCmd))
+UpdateGRASSAddOnCommands()
"""@Toolbar icon size"""
toolbarSize = (24, 24)
Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py 2012-10-18 11:50:40 UTC (rev 53466)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py 2012-10-18 15:02:00 UTC (rev 53467)
@@ -1004,6 +1004,10 @@
"""!Reset focus"""
self.cmdPrompt.SetFocus()
+ def GetPrompt(self):
+ """!Get prompt"""
+ return self.cmdPrompt
+
class GMStdout:
"""!GMConsole standard output
Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py 2012-10-18 11:50:40 UTC (rev 53466)
+++ grass/trunk/gui/wxpython/modules/extensions.py 2012-10-18 15:02:00 UTC (rev 53467)
@@ -221,15 +221,11 @@
log.RunCmd(self._getCmd(), onDone = self.OnDone)
def OnDone(self, cmd, returncode):
- item = self.tree.GetSelected()
- if not item or not item.IsOk() or \
- returncode != 0 or \
- not os.getenv('GRASS_ADDON_BASE'):
- return
+ if returncode == 0:
+ globalvar.UpdateGRASSAddOnCommands()
+ log = self.parent.GetLogWindow()
+ log.GetPrompt().SetFilter(None)
- name = self.tree.GetItemText(item)
- globalvar.grassCmd.add(name)
-
def OnItemSelected(self, event):
"""!Item selected"""
item = event.GetItem()
More information about the grass-commit
mailing list