[GRASS-SVN] r65429 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 9 21:16:17 PDT 2015


Author: wenzeslaus
Date: 2015-06-09 21:16:17 -0700 (Tue, 09 Jun 2015)
New Revision: 65429

Modified:
   grass/trunk/lib/python/script/Makefile
   grass/trunk/lib/python/script/setup.py
Log:
pythonlib: use non-py extension for tmp file (r65345) to avoid picking of the file by autodoc, fix syntax in r65346

Modified: grass/trunk/lib/python/script/Makefile
===================================================================
--- grass/trunk/lib/python/script/Makefile	2015-06-10 03:43:30 UTC (rev 65428)
+++ grass/trunk/lib/python/script/Makefile	2015-06-10 04:16:17 UTC (rev 65429)
@@ -18,12 +18,12 @@
 $(DSTDIR)/%: % | $(DSTDIR)
 	$(INSTALL_DATA) $< $@
 
-EXTRA_CLEAN_FILES = setup.tmp.py
+EXTRA_CLEAN_FILES = setup.py.tmp
 
-$(DSTDIR)/setup.py: setup.tmp.py | $(DSTDIR)
+$(DSTDIR)/setup.py: setup.py.tmp | $(DSTDIR)
 	$(INSTALL_DATA) $< $@
 
-setup.tmp.py: setup.py
+setup.py.tmp: setup.py
 	sed \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
 	$< > $@

Modified: grass/trunk/lib/python/script/setup.py
===================================================================
--- grass/trunk/lib/python/script/setup.py	2015-06-10 03:43:30 UTC (rev 65428)
+++ grass/trunk/lib/python/script/setup.py	2015-06-10 04:16:17 UTC (rev 65429)
@@ -47,9 +47,9 @@
                  " {cmd}: {error}".format(cmd=startcmd[0], error=error))
     if p.returncode != 0:
         sys.exit("ERROR: Issues running GRASS GIS start script"
-                 " {cmd}:\n{error}"
+                 " {cmd}: {error}"
                  .format(cmd=' '.join(startcmd), error=err))
-    gisbase = out.strip('\n\r')
+    gisbase = out.strip(os.linesep)
 
     # set GISBASE environment variable
     os.environ['GISBASE'] = gisbase
@@ -109,6 +109,8 @@
     return gisrc
 
 
+# TODO: there should be a function to do the clean up
+# (unset the GISRC and delete the file)
 def init(gisbase, dbase='', location='demolocation', mapset='PERMANENT'):
     """Initialize system variables to run GRASS modules
 
@@ -126,12 +128,13 @@
 
     Basic usage::
 
-        # ... setup GISBASE and PYTHON path
-        grass.script as gscript
+        # ... setup GISBASE and PYTHON path before import
+        import grass.script as gscript
         gisrc = gscript.setup.init("/usr/lib/grass64",
                                    "/home/john/grassdata",
                                    "nc_spm_08", "user1")
-        # ... use GRASS modules
+        # ... use GRASS modules here
+        # remove the session's gisrc file to end the session
         os.remove(gisrc)
 
     :param gisbase: path to GRASS installation



More information about the grass-commit mailing list