[GRASS-SVN] r67232 - grass/trunk/gui/wxpython/core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 18 13:03:00 PST 2015


Author: martinl
Date: 2015-12-18 13:03:00 -0800 (Fri, 18 Dec 2015)
New Revision: 67232

Modified:
   grass/trunk/gui/wxpython/core/gconsole.py
Log:
wxGUI: implement mechanism which allows to pass giface to g.gui.* modules


Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2015-12-18 20:52:40 UTC (rev 67231)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2015-12-18 21:03:00 UTC (rev 67232)
@@ -491,15 +491,34 @@
                                                                       'opt': p.get('name', '')})
                             return
 
-                if len(command) == 1 and hasParams and \
-                        command[0] != 'v.krige':
-                    # no arguments given
-                    try:
-                        GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
-                    except GException as e:
-                        print >> sys.stderr, e
-                    return
-
+                if len(command) == 1:
+                    if command[0].startswith('g.gui.'):
+                        import imp
+                        import inspect
+                        pyFile = command[0]
+                        if sys.platform == 'win32':
+                            pyFile += '.py'
+                        pyPath = os.path.join(os.environ['GISBASE'], 'scripts', pyFile)
+                        if not os.path.exists(pyPath):
+                            pyPath = os.path.join(os.environ['GRASS_ADDON_BASE'], 'scripts', pyFile)
+                        if not os.path.exists(pyPath):
+                            GError(parent=self._guiparent,
+                                   message=_("Module <%s> not found.") % command[0])
+                        pymodule = imp.load_source(command[0].replace('.', '_'), pyPath)
+                        pymain = inspect.getargspec(pymodule.main)
+                        if pymain and 'giface' in pymain.args:
+                            pymodule.main(self._giface)
+                            return
+                    
+                    if hasParams and command[0] != 'v.krige':
+                        # no arguments given
+                        try:
+                            GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
+                        except GException as e:
+                            print >> sys.stderr, e
+                        
+                        return
+                
                 # activate computational region (set with g.region)
                 # for all non-display commands.
                 if compReg:



More information about the grass-commit mailing list