[GRASS-SVN] r60182 - grass/branches/releasebranch_7_0/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 11 10:00:33 PDT 2014
Author: neteler
Date: 2014-05-11 10:00:33 -0700 (Sun, 11 May 2014)
New Revision: 60182
Modified:
grass/branches/releasebranch_7_0/lib/init/grass.py
Log:
startup script: added flag -e in startup script to exit after creation of location or mapset (backport from trunk: r60146 + r60147)
Modified: grass/branches/releasebranch_7_0/lib/init/grass.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/init/grass.py 2014-05-11 16:07:12 UTC (rev 60181)
+++ grass/branches/releasebranch_7_0/lib/init/grass.py 2014-05-11 17:00:33 UTC (rev 60182)
@@ -68,8 +68,8 @@
location = None
create_new = None
grass_gui = None
+exit_grass = None
-
def warning(text):
sys.stderr.write(_("WARNING") + ': ' + text + os.linesep)
@@ -168,13 +168,14 @@
%s:
$CMD_NAME [-h | -help | --help] [-v | --version] [-c | -c geofile | -c EPSG:code]
- [-text | -gui] [--config param]
+ [-e] [-text | -gui] [--config param]
[[[<GISDBASE>/]<LOCATION_NAME>/]<MAPSET>]
%s:
-h or -help or --help %s
-v or --version %s
-c %s
+ -e %s
-text %s
%s
-gtext %s
@@ -204,6 +205,7 @@
_("print this help message"),
_("show version information and exit"),
_("create given database, location or mapset if it doesn't exist"),
+ _("exit after creation of location or mapset. Only with -c flag"),
_("use text based interface (skip welcome screen)"),
_("and set as default"),
_("use text based interface (show welcome screen)"),
@@ -969,7 +971,7 @@
# TODO: uncomment when PDCurses works.
# cls
else:
- if not os.getenv('GRASS_BATCH_JOB') and not grass_debug:
+ if not os.getenv('GRASS_BATCH_JOB') and not grass_debug and not exit_grass:
call(["tput", "clear"])
@@ -1214,7 +1216,7 @@
def parse_cmdline():
- global args, grass_gui, create_new
+ global args, grass_gui, create_new, exit_grass
args = []
for i in sys.argv[1:]:
# Check if the user asked for the version
@@ -1240,6 +1242,8 @@
# Check if the user wants to create a new mapset
elif i == "-c":
create_new = True
+ elif i == "-e":
+ exit_grass = True
elif i == "--config":
print_params()
sys.exit()
@@ -1307,6 +1311,8 @@
# Parse the command-line options
parse_cmdline()
+if exit_grass and not create_new:
+ fatal(_("Flag -e required also flag -c"))
# Set language
# This has to be called before any _() function call!
# Subsequent functions are using _() calls and
@@ -1358,7 +1364,10 @@
else:
clean_temp()
-message(_("Starting GRASS GIS..."))
+if create_new:
+ message(_("Creating new GRASS GIS location/mapset..."))
+else:
+ message(_("Starting GRASS GIS..."))
# Check that the GUI works
check_gui()
@@ -1395,7 +1404,7 @@
check_batch_job()
-if not batch_job:
+if not batch_job and not exit_grass:
start_gui()
clear_screen()
@@ -1407,6 +1416,10 @@
clean_temp()
try_remove(lockfile)
sys.exit(0)
+elif exit_grass:
+ clean_temp()
+ try_remove(lockfile)
+ sys.exit(0)
else:
show_banner()
say_hello()
More information about the grass-commit
mailing list