[GRASS-SVN] r44392 - grass/trunk/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 23 09:49:11 EST 2010


Author: martinl
Date: 2010-11-23 06:49:11 -0800 (Tue, 23 Nov 2010)
New Revision: 44392

Modified:
   grass/trunk/lib/python/core.py
Log:
grass.init() added
(merge r44388 from devbr6)


Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2010-11-23 14:45:32 UTC (rev 44391)
+++ grass/trunk/lib/python/core.py	2010-11-23 14:49:11 UTC (rev 44392)
@@ -29,6 +29,7 @@
 import re
 import atexit
 import subprocess
+import tempfile as tmpfile
 
 # i18N
 import gettext
@@ -992,6 +993,22 @@
     
     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))



More information about the grass-commit mailing list