Explorar o código

wxGUI: use print function (no traceback, only proper error message with Python 3)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71833 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras %!s(int64=7) %!d(string=hai) anos
pai
achega
1f1f39bb75
Modificáronse 2 ficheiros con 17 adicións e 12 borrados
  1. 9 6
      gui/wxpython/core/globalvar.py
  2. 8 6
      gui/wxpython/gui_core/forms.py

+ 9 - 6
gui/wxpython/core/globalvar.py

@@ -11,6 +11,8 @@ This program is free software under the GNU General Public License
 @author Martin Landa <landa.martin gmail.com>
 """
 
+from __future__ import print_function
+
 import os
 import sys
 import locale
@@ -100,16 +102,17 @@ def CheckForWx(forceVersion=os.getenv('GRASS_WXVERSION', None)):
                 tuple(version.split('.')))
 
     except ImportError as e:
-        print >> sys.stderr, 'ERROR: wxGUI requires wxPython. %s' % str(e)
-        print >> sys.stderr, ('You can still use GRASS GIS modules in'
-                              ' the command line or in Python.')
+        print('ERROR: wxGUI requires wxPython. %s' % str(e),
+              file=sys.stderr)
+        print('You can still use GRASS GIS modules in'
+              ' the command line or in Python.', file=sys.stderr)
         sys.exit(1)
     except (ValueError, wxversion.VersionError) as e:
-        print >> sys.stderr, 'ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(
-            minVersion) + '%s.' % (str(e))
+        print('ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(
+              minVersion) + '%s.' % (str(e)), file=sys.stderr)
         sys.exit(1)
     except locale.Error as e:
-        print >> sys.stderr, "Unable to set locale:", e
+        print("Unable to set locale:", e, file=sys.stderr)
         os.environ['LC_ALL'] = ''
 
 if not os.getenv("GRASS_WXBUNDLED"):

+ 8 - 6
gui/wxpython/gui_core/forms.py

@@ -46,6 +46,8 @@ COPYING coming with GRASS for details.
 @author Stepan Turek <stepan.turek seznam.cz> (CoordinatesSelect)
 """
 
+from __future__ import print_function
+
 import sys
 import string
 import textwrap
@@ -835,10 +837,10 @@ class TaskFrame(wx.Frame):
 
                 ret = self._gconsole.RunCmd(cmd, onDone=self.OnDone)
             except AttributeError as e:
-                print >> sys.stderr, "%s: Probably not running in wxgui.py session?" % (
-                    e)
-                print >>sys.stderr, "parent window is: %s" % (
-                    str(self.parent))
+                print("%s: Probably not running in wxgui.py session?" % (
+                      e), file=sys.stderr)
+                print("parent window is: %s" % (
+                      str(self.parent)), file=sys.stderr)
         else:
             gcmd.Command(cmd)
 
@@ -3006,10 +3008,10 @@ if __name__ == "__main__":
             # the default parameter display is added automatically
             assert ' '.join(
                 task.get_cmd()) == "d.vect -i map=map_name layer=1 display=shape label_bcolor=red"
-            print "Creation of task successful"
+            print("Creation of task successful")
         # Test interface building with handmade grassTask,
         # possibly outside of a GRASS session.
-        print "Now creating a module dialog (task frame)"
+        print("Now creating a module dialog (task frame)")
         task = gtask.grassTask()
         task.name = "TestTask"
         task.description = "This is an artificial grassTask() object intended for testing purposes."