Browse Source

libgis: fix parser when GUI is not available and asked by user

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66914 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 years ago
parent
commit
272264d1d8
1 changed files with 16 additions and 8 deletions
  1. 16 8
      lib/gis/parser.c

+ 16 - 8
lib/gis/parser.c

@@ -119,7 +119,7 @@ static void check_multiple_opts(void);
 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 @@ int G_parser(int argc, char **argv)
 
     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 @@ int G_parser(int argc, char **argv)
 
     /* 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 @@ void define_keywords(void)
 /*!
   \brief Invoke GUI dialog
 */
-void module_gui_wx(void)
+int module_gui_wx(void)
 {
     char script[GPATH_MAX];
 
@@ -836,8 +838,14 @@ void module_gui_wx(void)
 	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)