Browse Source

grass.py: add -gtext switch

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59379 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
063ab77241
2 changed files with 32 additions and 31 deletions
  1. 22 15
      lib/init/grass.py
  2. 10 16
      lib/init/variables.html

+ 22 - 15
lib/init/grass.py

@@ -126,7 +126,7 @@ def cleanup():
 
 
 
 
 def fatal(msg):
 def fatal(msg):
-    sys.stderr.write(msg + os.linesep)
+    sys.stderr.write("%s: " % _('ERROR') + msg + os.linesep)
     sys.exit(_("Exiting..."))
     sys.exit(_("Exiting..."))
 
 
 
 
@@ -177,6 +177,8 @@ Geographic Resources Analysis Support System (GRASS GIS).
   -c                             %s
   -c                             %s
   -text                          %s
   -text                          %s
                                    %s
                                    %s
+  -gtext                         %s
+                                   %s
   -gui                           %s
   -gui                           %s
                                    %s
                                    %s
   --config                       %s
   --config                       %s
@@ -202,7 +204,9 @@ Geographic Resources Analysis Support System (GRASS GIS).
        _("print this help message"),
        _("print this help message"),
        _("show version information and exit"),
        _("show version information and exit"),
        _("create given database, location or mapset if it doesn't exist"),
        _("create given database, location or mapset if it doesn't exist"),
-       _("use text based interface"),
+       _("use text based interface (skip welcome screen)"),
+       _("and set as default"),
+       _("use text based interface (show welcome screen)"),
        _("and set as default"),
        _("and set as default"),
        _("use $DEFAULT_GUI graphical user interface"),
        _("use $DEFAULT_GUI graphical user interface"),
        _("and set as default"),
        _("and set as default"),
@@ -525,7 +529,7 @@ def check_gui():
     # Check if we are running X windows by checking the DISPLAY variable
     # Check if we are running X windows by checking the DISPLAY variable
     if os.getenv('DISPLAY') or windows or macosx:
     if os.getenv('DISPLAY') or windows or macosx:
         # Check if python is working properly
         # Check if python is working properly
-        if grass_gui == 'wxpython':
+        if grass_gui in ('wxpython', 'gtext'):
             nul = open(os.devnull, 'w')
             nul = open(os.devnull, 'w')
             p = Popen([os.environ['GRASS_PYTHON']], stdin=subprocess.PIPE,
             p = Popen([os.environ['GRASS_PYTHON']], stdin=subprocess.PIPE,
                       stdout=nul, stderr=nul)
                       stdout=nul, stderr=nul)
@@ -675,22 +679,22 @@ def set_data():
         if grass_gui == 'text':
         if grass_gui == 'text':
             pass
             pass
         # Check for GUI
         # Check for GUI
-        elif grass_gui == 'wxpython':
-            gui_startup()
+        elif grass_gui in ('gtext', 'wxpython'):
+            gui_startup(grass_gui == 'gtext')
         else:
         else:
             # Shouldn't need this but you never know
             # Shouldn't need this but you never know
-            fatal(_("Invalid user interface specified - <%s>.\n" 
+            fatal(_("Invalid user interface specified - <%s>. " 
                     "Use the --help option to see valid interface names.") % grass_gui)
                     "Use the --help option to see valid interface names.") % grass_gui)
 
 
 
 
-def gui_startup():
-    if grass_gui == 'wxpython':
-        thetest = call([os.getenv('GRASS_PYTHON'),
+def gui_startup(wscreen_only = False):
+    if grass_gui in ('wxpython', 'gtext'):
+        ret = call([os.getenv('GRASS_PYTHON'),
                         gfile(wxpython_base, "gis_set.py")])
                         gfile(wxpython_base, "gis_set.py")])
 
 
-    if thetest == 0:
+    if ret == 0:
         pass
         pass
-    elif thetest == 1:
+    elif ret == 1:
         # The startup script printed an error message so wait
         # The startup script printed an error message so wait
         # for user to read it
         # for user to read it
         message(_("Error in GUI startup. If necessary, please "
         message(_("Error in GUI startup. If necessary, please "
@@ -701,7 +705,7 @@ def gui_startup():
 
 
         os.execlp(cmd_name, "-text")
         os.execlp(cmd_name, "-text")
         sys.exit(1)
         sys.exit(1)
-    elif thetest == 2:
+    elif ret == 2:
         # User wants to exit from GRASS
         # User wants to exit from GRASS
         message(_("Received EXIT message from GUI.\nGRASS is not started. Bye."))
         message(_("Received EXIT message from GUI.\nGRASS is not started. Bye."))
         sys.exit(0)
         sys.exit(0)
@@ -861,9 +865,9 @@ def check_lock():
 
 
     if msg:
     if msg:
         if grass_gui == "wxpython":
         if grass_gui == "wxpython":
-            thetest = call([os.getenv('GRASS_PYTHON'),
-                            os.path.join(wxpython_base, "gis_set_error.py"),
-                            msg])
+            call([os.getenv('GRASS_PYTHON'),
+                  os.path.join(wxpython_base, "gis_set_error.py"),
+                  msg])
         else:
         else:
             global remove_lockfile
             global remove_lockfile
             remove_lockfile = False
             remove_lockfile = False
@@ -1215,6 +1219,9 @@ def parse_cmdline():
         # Check if the -text flag was given
         # Check if the -text flag was given
         elif i in ["-text", "--text"]:
         elif i in ["-text", "--text"]:
             grass_gui = 'text'
             grass_gui = 'text'
+        # Check if the -gtext flag was given
+        elif i in ["-gtext", "--gtext"]:
+            grass_gui = 'gtext'
         # Check if the -gui flag was given
         # Check if the -gui flag was given
         elif i in ["-gui", "--gui"]:
         elif i in ["-gui", "--gui"]:
             grass_gui = default_gui
             grass_gui = default_gui

+ 10 - 16
lib/init/variables.html

@@ -137,15 +137,15 @@ PERMANENT
     program to use for plotting <em>gnuplot</em> data.</dd>
     program to use for plotting <em>gnuplot</em> data.</dd>
   
   
   <dt>GRASS_GUI</dt>
   <dt>GRASS_GUI</dt>
-  <dd>either <tt>text</tt> or <tt>gui</tt> to define non-/graphical startup.
-    <br><br> Can also specify the name of the GUI to use,
-    e.g. <tt>wxpython</tt>
-    (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a GRASS
-    gisenv variable (see below). If this shell variable exists at
-    GRASS startup, it will determine the GUI used. If it is not
-    defined startup will default to the last GUI used.</dd>
-  
-  
+  <dd>either <tt>text</tt> (text user interface), <tt>gtext</tt> (text
+  user interface with GUI welcome screen), or <tt>gui</tt> (graphical
+  user interface) to define non-/graphical startup. Can also specify
+  the name of the GUI to use, e.g. <tt>wxpython</tt>
+  (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a GRASS
+  gisenv variable (see below). If this shell variable exists at GRASS
+  startup, it will determine the GUI used. If it is not defined
+  startup will default to the last GUI used.</dd>
+    
   <dt>GRASS_HTML_BROWSER</dt>
   <dt>GRASS_HTML_BROWSER</dt>
   <dd>[init.sh, wxgui]<br> defines name of HTML browser. For most
   <dd>[init.sh, wxgui]<br> defines name of HTML browser. For most
     platforms this should be an executable in your PATH, or the full
     platforms this should be an executable in your PATH, or the full
@@ -436,13 +436,7 @@ g.gisenv set=DEBUG=0
     encoding of query form (utf-8, ascii, iso8859-1, koi8-r)</dd>
     encoding of query form (utf-8, ascii, iso8859-1, koi8-r)</dd>
   
   
   <dt>GUI</dt>
   <dt>GUI</dt>
-  <dd>either <tt>text</tt> or <tt>gui</tt> to define non-/graphical startup.
-    <br><br> Can also specify the name of the GUI to use,
-    e.g. <tt>wxpython</tt>
-    (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a shell
-    environment variable. If this shell variable exists at GRASS
-    startup, it will determine the GUI used. If it is not defined
-    startup will default to the last GUI used.</dd>
+  <dd>See <tt>GRASS_GUI</tt> environmental variable for details.</dd>
   
   
   <dt>LOCATION</dt>
   <dt>LOCATION</dt>
   <dd>full path to location directory</dd>
   <dd>full path to location directory</dd>