[GRASS-SVN] r35281 - grass/trunk/scripts/d.rast.edit

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 7 21:10:26 EST 2009


Author: glynn
Date: 2009-01-07 21:10:26 -0500 (Wed, 07 Jan 2009)
New Revision: 35281

Modified:
   grass/trunk/scripts/d.rast.edit/d.rast.edit.py
Log:
Try to fail more gracefully if wx isn't present (--help etc should still work)


Modified: grass/trunk/scripts/d.rast.edit/d.rast.edit.py
===================================================================
--- grass/trunk/scripts/d.rast.edit/d.rast.edit.py	2009-01-08 01:58:44 UTC (rev 35280)
+++ grass/trunk/scripts/d.rast.edit/d.rast.edit.py	2009-01-08 02:10:26 UTC (rev 35281)
@@ -4,7 +4,7 @@
 #
 # MODULE:       d.rast.edit
 # AUTHOR(S):    Glynn Clements <glynn at gclements.plus.com>
-# COPYRIGHT:    (C) 2007,2008 Glynn Clements
+# COPYRIGHT:    (C) 2007,2008,2009 Glynn Clements
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -90,16 +90,27 @@
 #% answer: 100
 #%End
 
-import wxversion
-wxversion.select(['2.8','2.6'])
-#wxversion.select(['2.6','2.8'])
-import wx
-
 import sys
 import math
 import atexit
 import grass
 
+try:
+    import wxversion
+    wxversion.select(['2.8','2.6'])
+    # wxversion.select(['2.6','2.8'])
+    import wx
+except Exception:
+    # ensure that --help, --interface-description etc work even without wx
+    if __name__ == "__main__":
+	if len(sys.argv) == 2:
+	    arg = sys.argv[1]
+	    if arg[0:2] == '--' or arg in ["help", "-help"]:
+		grass.parser()
+    # Either we didn't call g.parser, or it returned
+    # At this point, there's nothing to be done except re-raise the exception
+    raise
+
 wind_keys = {
     'north': ('n', float),
     'south': ('s', float),



More information about the grass-commit mailing list