Browse Source

Try to fail more gracefully if wx isn't present (--help etc should still work)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35281 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 years ago
parent
commit
69a2803645
1 changed files with 17 additions and 6 deletions
  1. 17 6
      scripts/d.rast.edit/d.rast.edit.py

+ 17 - 6
scripts/d.rast.edit/d.rast.edit.py

@@ -4,7 +4,7 @@
 #
 #
 # MODULE:       d.rast.edit
 # MODULE:       d.rast.edit
 # AUTHOR(S):    Glynn Clements <glynn@gclements.plus.com>
 # AUTHOR(S):    Glynn Clements <glynn@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
 #  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
 #  it under the terms of the GNU General Public License as published by
@@ -90,16 +90,27 @@
 #% answer: 100
 #% answer: 100
 #%End
 #%End
 
 
-import wxversion
-wxversion.select(['2.8','2.6'])
-#wxversion.select(['2.6','2.8'])
-import wx
-
 import sys
 import sys
 import math
 import math
 import atexit
 import atexit
 import grass
 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 = {
 wind_keys = {
     'north': ('n', float),
     'north': ('n', float),
     'south': ('s', float),
     'south': ('s', float),