فهرست منبع

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).


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69360 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 سال پیش
والد
کامیت
924b2e6236
1فایلهای تغییر یافته به همراه9 افزوده شده و 8 حذف شده
  1. 9 8
      gui/wxpython/gui_core/forms.py

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

@@ -58,11 +58,6 @@ import codecs
 
 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 @@ try:
 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