|
@@ -29,6 +29,7 @@ import types
|
|
|
import re
|
|
|
import atexit
|
|
|
import subprocess
|
|
|
+import tempfile as tmpfile
|
|
|
|
|
|
# i18N
|
|
|
import gettext
|
|
@@ -992,6 +993,22 @@ def _create_location_xy(location):
|
|
|
|
|
|
return 0
|
|
|
|
|
|
+def init(gisbase, dbase, location, mapset):
|
|
|
+ os.environ['PATH'] += ':' + os.path.join(gisbase, 'bin') + ':' + \
|
|
|
+ os.path.join(gisbase, 'scripts')
|
|
|
+ os.environ['LD_LIBRARY_PATH'] = os.path.join(gisbase, 'lib')
|
|
|
+
|
|
|
+ os.environ['GIS_LOCK'] = str(os.getpid())
|
|
|
+
|
|
|
+ fd, gisrc = tmpfile.mkstemp()
|
|
|
+ os.environ['GISRC'] = gisrc
|
|
|
+ fd.write("GISDBASE: %s\n" % dbase)
|
|
|
+ fd.write("LOCATION_NAME: %s\n" % location)
|
|
|
+ fd.write("MAPSET: %s\n" % mapset)
|
|
|
+ fd.close()
|
|
|
+
|
|
|
+ return gisrc
|
|
|
+
|
|
|
# get debug_level
|
|
|
if find_program('g.gisenv', ['--help']):
|
|
|
debug_level = int(gisenv().get('DEBUG', 0))
|