[GRASS-SVN] r48247 - grass/trunk/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 12 08:00:39 EDT 2011
Author: martinl
Date: 2011-09-12 05:00:38 -0700 (Mon, 12 Sep 2011)
New Revision: 48247
Added:
grass/trunk/lib/init/prompt.py
Modified:
grass/trunk/lib/init/Makefile
grass/trunk/lib/init/grass.py
Log:
introduce prompt.py (check for mask)
Modified: grass/trunk/lib/init/Makefile
===================================================================
--- grass/trunk/lib/init/Makefile 2011-09-12 08:43:58 UTC (rev 48246)
+++ grass/trunk/lib/init/Makefile 2011-09-12 12:00:38 UTC (rev 48247)
@@ -27,6 +27,7 @@
$(ETC)/license \
$(ETC)/welcome \
$(ETC)/VERSIONNUMBER \
+ $(ETC)/prompt.py \
$(HTMLDIR)/variables.html \
$(HTMLDIR)/grass7.html \
$(HTMLDIR)/helptext.html \
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2011-09-12 08:43:58 UTC (rev 48246)
+++ grass/trunk/lib/init/grass.py 2011-09-12 12:00:38 UTC (rev 48247)
@@ -810,6 +810,7 @@
f = open(bashrc, 'w')
f.write("test -r ~/.alias && . ~/.alias\n")
f.write("PS1='GRASS %s (%s@%s):\w > '\n" % (grass_version, location_name, mapset))
+ f.write("PROMPT_COMMAND=\"'%s'\"\n" % os.path.join(gisbase, 'etc', 'prompt.py'))
path = os.path.join(userhome, ".grass.bashrc")
if os.access(path, os.R_OK):
Added: grass/trunk/lib/init/prompt.py
===================================================================
--- grass/trunk/lib/init/prompt.py (rev 0)
+++ grass/trunk/lib/init/prompt.py 2011-09-12 12:00:38 UTC (rev 48247)
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+from grass.script import core as grass
+
+gisenv = grass.gisenv()
+
+import gettext
+gettext.install('grasslibs', os.path.join(gisenv['GISDBASE'], 'locale'), unicode = True)
+
+location = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'], gisenv['MAPSET'])
+
+has_mask = os.path.isfile(os.path.join(location, 'cell', 'MASK'))
+has_mask3d = os.path.isdir(os.path.join(location, 'grid3', 'G3D_MASK'))
+
+def main():
+ if has_mask and has_mask3d:
+ grass.info(_("[Raster and Volume MASKs present]"))
+ elif has_mask:
+ grass.info(_("[Raster MASK present]"))
+ elif has_mask3d:
+ grass.info(_("[Volume MASK present]"))
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main())
Property changes on: grass/trunk/lib/init/prompt.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list