HI,
attached a new attempt to generate a new location within a Python
script (goal: batch processing).
All fine except for the fact that GRASS 7 started with -c ... creates
a location but then actually *starts* the session rather than
returning.
How to overcome this issue?
thanks
Markus
#!/usr/bin/env python
# Python script to generate a new GRASS GIS 7 location from metadata
import os
import sys
import subprocess
import binascii
# some predefined variables
grass7bin = 'grass71'
myepsg = '4326' # latlong
########
# define GRASS DATABASE
gisdb = os.path.join(os.path.expanduser("~"), "grassdata")
# location/mapset: use random names for batch jobs
string_length = 16
location = binascii.hexlify(os.urandom(string_length))
mapset = binascii.hexlify(os.urandom(string_length))
# create new location
# grass71 -c epsg:4326 ~/grassdata/mylocation
startcmd = grass7bin + ' -c epsg:' + myepsg + ' ' + gisdb + os.sep + location
# TODO: the start script should not start the new session!
p = subprocess.Popen(startcmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
print >>sys.stderr, "ERROR: Cannot generate location (%s)" % startcmd
sys.exit(-1)
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev