[GRASS-SVN] r44104 - in grass/trunk: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 30 12:00:18 EDT 2010


Author: martinl
Date: 2010-10-30 09:00:18 -0700 (Sat, 30 Oct 2010)
New Revision: 44104

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/lib/python/core.py
Log:
grass.find_program(): Windows-related fix
(merge r44102 devbr6)


Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-10-30 15:52:25 UTC (rev 44103)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-10-30 16:00:18 UTC (rev 44104)
@@ -700,31 +700,30 @@
         self.console_progressbar.SetValue(0) # reset progress bar on '0%'
 
         self.cmd_output_timer.Stop()
-
-        # set focus on prompt
+        
         if self.parent.GetName() == "LayerManager":
             self.btn_abort.Enable(False)
+            if event.cmd[0] not in globalvar.grassCmd['all']:
+                return
             display = self.parent.GetLayerTree().GetMapDisplay()
-            if display and display.IsAutoRendered():
-                mapLayers = map(lambda x: x.GetName(),
-                                display.GetRender().GetListOfLayers(l_type = 'raster') +
-                                display.GetRender().GetListOfLayers(l_type = 'vector'))
-                
-                task = menuform.GUI().ParseCommand(event.cmd, show = None)
-                for p in task.get_options()['params']:
-                    if p.get('prompt', '') not in ('raster', 'vector'):
-                        continue
-                    mapName = p.get('value', '')
-                    if '@' not in mapName:
-                        mapName = mapName + '@' + grass.gisenv()['MAPSET']
-                    if mapName in mapLayers:
-                        display.GetWindow().UpdateMap(render = True)
-                        return
+            if not display or not display.IsAutoRendered():
+                return
+            mapLayers = map(lambda x: x.GetName(),
+                            display.GetRender().GetListOfLayers(l_type = 'raster') +
+                            display.GetRender().GetListOfLayers(l_type = 'vector'))
             
-        else:
-            # updated command dialog
+            task = menuform.GUI().ParseCommand(event.cmd, show = None)
+            for p in task.get_options()['params']:
+                if p.get('prompt', '') not in ('raster', 'vector'):
+                    continue
+                mapName = p.get('value', '')
+                if '@' not in mapName:
+                    mapName = mapName + '@' + grass.gisenv()['MAPSET']
+                if mapName in mapLayers:
+                    display.GetWindow().UpdateMap(render = True)
+                    return
+        else: # standalone dialogs
             dialog = self.parent.parent
-
             if hasattr(self.parent.parent, "btn_abort"):
                 dialog.btn_abort.Enable(False)
             
@@ -784,8 +783,6 @@
                 time.sleep(1)
                 dialog.Close()
         
-        event.Skip()
-        
     def OnProcessPendingOutputWindowEvents(self, event):
         self.ProcessPendingEvents()
 

Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2010-10-30 15:52:25 UTC (rev 44103)
+++ grass/trunk/lib/python/core.py	2010-10-30 16:00:18 UTC (rev 44104)
@@ -760,19 +760,25 @@
 # find a program (replacement for "which")
 
 def find_program(pgm, args = []):
-    """!Attempt to run a program, with optional arguments. Return False
-    if the attempt failed due to a missing executable, True otherwise
+    """!Attempt to run a program, with optional arguments. 
 
     @param pgm program name
     @param args list of arguments
+
+    @return False if the attempt failed due to a missing executable
+    @return True otherwise
     """
     nuldev = file(os.devnull, 'w+')
     try:
-	call([pgm] + args, stdin = nuldev, stdout = nuldev, stderr = nuldev)
-	found = True
+	ret = call([pgm] + args, stdin = nuldev, stdout = nuldev, stderr = nuldev)
+        if ret == 0:
+            found = True
+        else:
+            found = False
     except:
 	found = False
     nuldev.close()
+    
     return found
 
 # try to remove a file, without complaints



More information about the grass-commit mailing list