[GRASS-SVN] r46296 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 14 19:35:46 EDT 2011


Author: martinl
Date: 2011-05-14 16:35:46 -0700 (Sat, 14 May 2011)
New Revision: 46296

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
Log:
mmetz: attempt to fix #1362
      (merge r46295 from devbr6)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py	2011-05-14 23:32:18 UTC (rev 46295)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py	2011-05-14 23:35:46 UTC (rev 46296)
@@ -583,9 +583,11 @@
     @return returncode, stdout, messages (read == True and getErrorMsg == True)
     @return stdout, stderr
     """
-    Debug.msg(1, "gcmd.RunCommand(): %s" % ' '.join(grass.make_command(prog, flags, overwrite,
-                                                                       quiet, verbose, **kwargs)))
+    cmdString = ' '.join(grass.make_command(prog, flags, overwrite,
+                                            quiet, verbose, **kwargs))
     
+    Debug.msg(1, "gcmd.RunCommand(): %s" % cmdString)
+    
     kwargs['stderr'] = subprocess.PIPE
     
     if read:
@@ -596,29 +598,48 @@
     
     ps = grass.start_command(prog, flags, overwrite, quiet, verbose, **kwargs)
     
+    Debug.msg(2, "gcmd.RunCommand(): command started")
+
     if stdin:
         ps.stdin.write(stdin)
         ps.stdin.close()
         ps.stdin = None
     
+    Debug.msg(3, "gcmd.RunCommand(): decoding string")
     stdout, stderr = map(lambda x: utils.DecodeString(x) if type(x) is types.StringType else x, ps.communicate())
     
     ret = ps.returncode
+    Debug.msg(1, "gcmd.RunCommand(): get return code %d" % ret)
         
-    if ret != 0 and parent: 
-        GError(parent = parent,
-               message = stderr)
+    Debug.msg(3, "gcmd.RunCommand(): print error")
+    if ret != 0 and parent:
+        Debug.msg(2, "gcmd.RunCommand(): error %s" % stderr)
+        if (stderr == None):
+            Debug.msg(2, "gcmd.RunCommand(): nothing to print ???")
+        else:
+            GError(parent = parent,
+                   message = stderr)
+
+    if ret != 0:
+        return None
     
+    Debug.msg(3, "gcmd.RunCommand(): print read error")
     if not read:
         if not getErrorMsg:
             return ret
         else:
             return ret, _formatMsg(stderr)
 
+    if stdout:
+        Debug.msg(2, "gcmd.RunCommand(): return stdout\n'%s'" % stdout)
+    else:
+        Debug.msg(2, "gcmd.RunCommand(): return stdout = None")
     if not getErrorMsg:
         return stdout
     
+    Debug.msg(2, "gcmd.RunCommand(): return ret, stdout")
     if read and getErrorMsg:
         return ret, stdout, _formatMsg(stderr)
     
+    Debug.msg(2, "gcmd.RunCommand(): return result")
     return stdout, _formatMsg(stderr)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py	2011-05-14 23:32:18 UTC (rev 46295)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py	2011-05-14 23:35:46 UTC (rev 46296)
@@ -652,21 +652,21 @@
         
     def InsertLayers(self, vector):
         """!Insert layers for a vector into the layer combobox"""
-        layerchoices = utils.GetVectorNumberOfLayers(vector)
+        layerchoices = utils.GetVectorNumberOfLayers(self, vector)
         for layer in self.initial:
             if layer in layerchoices:
                 continue
             layerchoices.append(layer)
         
-        # sort list of available layers
-        utils.ListSortLower(layerchoices)
-        
+        if len(layerchoices) == 0:
+            layerchoices.insert(0, '-1')
         if len(layerchoices) > 1:
             self.SetItems(layerchoices)
             self.SetStringSelection('1')
-        else:
-            self.SetItems(['1'])
-            self.SetStringSelection('1')
+        elif len(layerchoices) == 1:
+            print layerchoices[0]
+            self.SetItems(layerchoices)
+            self.SetStringSelection(layerchoices[0])
         
         if self.default:
             self.SetStringSelection(str(self.default))

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py	2011-05-14 23:32:18 UTC (rev 46295)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py	2011-05-14 23:35:46 UTC (rev 46296)
@@ -272,7 +272,7 @@
     """!Sort list items (not case-sensitive)"""
     list.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
 
-def GetVectorNumberOfLayers(vector):
+def GetVectorNumberOfLayers(parent, vector):
     """!Get list of vector layers"""
     layers = []
     if not vector:
@@ -284,6 +284,7 @@
         return layers
     
     ret = gcmd.RunCommand('v.db.connect',
+                          parent = parent,
                           flags = 'g',
                           read = True,
                           map = fullname,
@@ -291,6 +292,8 @@
         
     if not ret:
         return layers
+    else:
+        Debug.msg(1, "GetVectorNumberOfLayers(): ret %s" % ret)
     
     for line in ret.splitlines():
         try:



More information about the grass-commit mailing list