[GRASS-SVN] r69360 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 3 10:59:13 PDT 2016


Author: wenzeslaus
Date: 2016-09-03 10:59:13 -0700 (Sat, 03 Sep 2016)
New Revision: 69360

Modified:
   grass/trunk/gui/wxpython/gui_core/forms.py
Log:
wxGUI/forms: simply fail when GISBASE is not set

The subsequent imports will likely fail anyway.
Moreover, the code was not actually working (there is
no sys.write) and global variable gisbase was unused.

Also call set_gui_path() function only when needed
(i.e. not when running as part of main GUI).


Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2016-09-03 17:05:42 UTC (rev 69359)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2016-09-03 17:59:13 UTC (rev 69360)
@@ -58,11 +58,6 @@
 
 from threading import Thread
 
-if not os.getenv("GISBASE"):
-    sys.write("We don't seem to be properly installed, or we are being run "
-              "outside GRASS. Expect glitches.\n")
-    gisbase = os.path.join(os.path.dirname(sys.argv[0]), os.path.pardir)
-
 import wx
 try:
     import wx.lib.agw.flatnotebook as FN
@@ -77,14 +72,20 @@
 except ImportError:
     import elementtree.ElementTree as etree  # Python <= 2.4
 
+# needed when started from command line and for testing
+if __name__ == '__main__':
+    if os.getenv("GISBASE") is None:
+        # intentionally not translatable
+        sys.exit("Failed to start. GRASS GIS is not running"
+                 " or the installation is broken.")
+    from grass.script.setup import set_gui_path
+    set_gui_path()
+
 from grass.pydispatch.signal import Signal
 
 from grass.script import core as grass
 from grass.script import task as gtask
 
-from grass.script.setup import set_gui_path
-set_gui_path()
-
 from core import globalvar
 from gui_core.widgets import StaticWrapText, ScrolledPanel, ColorTablesComboBox, \
     BarscalesComboBox, NArrowsComboBox



More information about the grass-commit mailing list