[GRASS-SVN] r66957 - in grass/branches/releasebranch_7_0: general/g.gui lib/gis lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 28 01:37:45 PST 2015


Author: martinl
Date: 2015-11-28 01:37:45 -0800 (Sat, 28 Nov 2015)
New Revision: 66957

Modified:
   grass/branches/releasebranch_7_0/general/g.gui/main.c
   grass/branches/releasebranch_7_0/lib/gis/parser.c
   grass/branches/releasebranch_7_0/lib/init/grass.py
Log:
grass.py: fix initialization script when gis_set.py is not available, explain to the user how to solve this issue
g.gui: ends with fatal error, when GUI is not available
libgis: fix parser when GUI is not available and asked by user
        (merge r66912:4, r66916)


Modified: grass/branches/releasebranch_7_0/general/g.gui/main.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.gui/main.c	2015-11-28 09:18:14 UTC (rev 66956)
+++ grass/branches/releasebranch_7_0/general/g.gui/main.c	2015-11-28 09:37:45 UTC (rev 66957)
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/spawn.h>
@@ -95,6 +97,8 @@
 
     G_message(_("Launching <%s> GUI in the background, please wait..."), type->answer);
     sprintf(progname, "%s/gui/wxpython/wxgui.py", G_gisbase());
+    if (access(progname, F_OK) == -1)
+        G_fatal_error(_("Your installation doesn't include GUI, exiting."));
     if (rc_file->answer) {
         G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
                    "--workspace", rc_file->answer, SF_BACKGROUND, NULL);

Modified: grass/branches/releasebranch_7_0/lib/gis/parser.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/gis/parser.c	2015-11-28 09:18:14 UTC (rev 66956)
+++ grass/branches/releasebranch_7_0/lib/gis/parser.c	2015-11-28 09:37:45 UTC (rev 66957)
@@ -119,7 +119,7 @@
 static int check_overwrite(void);
 static void define_keywords(void);
 static void split_gisprompt(const char *, char *, char *, char *);
-static void module_gui_wx(void);
+static int module_gui_wx(void);
 static void append_error(const char *);
 static const char *get_renamed_option(const char *);
 
@@ -433,10 +433,11 @@
 
     if (argc < 2 && (st->has_required || G__has_required_rule())
         && !st->no_interactive && isatty(0)) {
-	module_gui_wx();
-	return -1;
+	if (module_gui_wx() == 0)
+            return -1;
     }
-    else if (argc < 2 && st->has_required && isatty(0)) {
+    
+    if (argc < 2 && st->has_required && isatty(0)) {
       	G_usage();
 	return -1;
     }
@@ -573,7 +574,8 @@
 
     /* Run the gui if it was specifically requested */
     if (force_gui) {
-	module_gui_wx();
+	if (module_gui_wx() != 0)
+            G_fatal_error(_("Your installation doesn't include GUI, exiting."));
 	return -1;
     }
 
@@ -826,7 +828,7 @@
 /*!
   \brief Invoke GUI dialog
 */
-void module_gui_wx(void)
+int module_gui_wx(void)
 {
     char script[GPATH_MAX];
 
@@ -836,8 +838,14 @@
 	G_fatal_error(_("Unable to determine program name"));
 
     sprintf(script, "%s/gui/wxpython/gui_core/forms.py",
-	    getenv("GISBASE"));
-    G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), script, G_recreate_command(), NULL);
+            getenv("GISBASE"));
+    if (access(script, F_OK) != -1)
+        G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"),
+                script, G_recreate_command(), NULL);
+    else
+        return -1;
+
+    return 0;
 }
 
 void set_flag(int f)

Modified: grass/branches/releasebranch_7_0/lib/init/grass.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/init/grass.py	2015-11-28 09:18:14 UTC (rev 66956)
+++ grass/branches/releasebranch_7_0/lib/init/grass.py	2015-11-28 09:37:45 UTC (rev 66957)
@@ -672,7 +672,13 @@
             pass
         # Check for GUI
         elif grass_gui in ('gtext', 'wxpython'):
-            gui_startup(grass_gui == 'gtext')
+            if not os.path.exists(gfile(wxpython_base, "gis_set.py")):
+                # No GUI available, update gisrc file
+                fatal(_("<{}> requested, but not available. Run GRASS in text "
+                        "mode (-text) or install missing package (usually "
+                        "'grass-gui').").format(grass_gui))
+            else:
+                gui_startup(grass_gui == 'gtext')
         else:
             # Shouldn't need this but you never know
             fatal(_("Invalid user interface specified - <%s>. " 



More information about the grass-commit mailing list