Bladeren bron

added flag -e in startup script to exit after creation of location or mapset

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60146 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 11 jaren geleden
bovenliggende
commit
cf54fe008c
1 gewijzigde bestanden met toevoegingen van 14 en 4 verwijderingen
  1. 14 4
      lib/init/grass.py

+ 14 - 4
lib/init/grass.py

@@ -68,7 +68,7 @@ remove_lockfile = True
 location = None
 location = None
 create_new = None
 create_new = None
 grass_gui = None
 grass_gui = None
-
+exit_grass = None
 
 
 def warning(text):
 def warning(text):
     sys.stderr.write(_("WARNING") + ': ' + text + os.linesep)
     sys.stderr.write(_("WARNING") + ': ' + text + os.linesep)
@@ -168,13 +168,14 @@ Geographic Resources Analysis Support System (GRASS GIS).
 
 
 %s:
 %s:
   $CMD_NAME [-h | -help | --help] [-v | --version] [-c | -c geofile | -c EPSG:code]
   $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>]
           [[[<GISDBASE>/]<LOCATION_NAME>/]<MAPSET>]
 
 
 %s:
 %s:
   -h or -help or --help          %s
   -h or -help or --help          %s
   -v or --version                %s
   -v or --version                %s
   -c                             %s
   -c                             %s
+  -e                             %s
   -text                          %s
   -text                          %s
                                    %s
                                    %s
   -gtext                         %s
   -gtext                         %s
@@ -204,6 +205,7 @@ 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"),
+       _("exit after creation of location or mapset. Only with -c flag"),
        _("use text based interface (skip welcome screen)"),
        _("use text based interface (skip welcome screen)"),
        _("and set as default"),
        _("and set as default"),
        _("use text based interface (show welcome screen)"),
        _("use text based interface (show welcome screen)"),
@@ -1230,7 +1232,7 @@ def get_username():
 
 
 
 
 def parse_cmdline():
 def parse_cmdline():
-    global args, grass_gui, create_new
+    global args, grass_gui, create_new, exit_grass
     args = []
     args = []
     for i in sys.argv[1:]:
     for i in sys.argv[1:]:
         # Check if the user asked for the version
         # Check if the user asked for the version
@@ -1256,6 +1258,8 @@ def parse_cmdline():
         # Check if the user wants to create a new mapset
         # Check if the user wants to create a new mapset
         elif i == "-c":
         elif i == "-c":
             create_new = True
             create_new = True
+        elif i == "-e":
+            exit_grass = True
         elif i == "--config":
         elif i == "--config":
             print_params()
             print_params()
             sys.exit()
             sys.exit()
@@ -1323,6 +1327,8 @@ get_username()
 # Parse the command-line options
 # Parse the command-line options
 parse_cmdline()
 parse_cmdline()
 
 
+if exit_grass and not create_new:
+    fatal(_("Flag -e required also flag -c"))
 # Set language
 # Set language
 # This has to be called before any _() function call!
 # This has to be called before any _() function call!
 # Subsequent functions are using _() calls and
 # Subsequent functions are using _() calls and
@@ -1411,7 +1417,7 @@ if not os.access(os.path.join(location, "VAR"), os.F_OK):
 
 
 check_batch_job()
 check_batch_job()
 
 
-if not batch_job:       
+if not batch_job and not exit_grass:       
     start_gui()
     start_gui()
 
 
 clear_screen()
 clear_screen()
@@ -1423,6 +1429,10 @@ if batch_job:
     clean_temp()
     clean_temp()
     try_remove(lockfile)
     try_remove(lockfile)
     sys.exit(0)
     sys.exit(0)
+elif exit_grass:
+    clean_temp()
+    try_remove(lockfile)
+    sys.exit(0)
 else:
 else:
     show_banner()
     show_banner()
     say_hello()
     say_hello()