[GRASS-user] Silent commands in python

G. Allegri giohappy at gmail.com
Mon Dec 3 19:25:13 EST 2007


Take a look to PyWPS code. It deals with this kind of problems using
subprocess module [1].
In particular, go to the def GCmd inside this file [2]
Here is a sample command that calls it :
self.GCmd("r.mapcalc output=input+%f >&2" [3]

Hope it helps,
Giovanni

[1] http://docs.python.org/lib/module-subprocess.html
[2] https://wald.intevation.org/plugins/scmsvn/viewcvs.php/trunk/pywps/Wps/process.py?rev=404&root=pywps&view=markup
[3] https://wald.intevation.org/plugins/scmsvn/viewcvs.php/trunk/pywps/processes/addvalue.py-dist?rev=370&root=pywps&view=markup


2007/12/4, Daniel Victoria <daniel.victoria at gmail.com>:
> Hi all,
>
> This might be more of a python problem but here it goes...
> I wrote a water balance script in python to run under GRASS. What I
> would like now is that the commands in the python script would be
> silent, that is, no return from stdout or stderr.
> For instance every time I call a r.mapcalc function I get the 0-100%
> count. I'd like to silence that and other commands.
>
> In the shell I would silence command outputs using &> /dev/null, for exemple:
> echo "blabla=2*bla" | r.mapcalc &> /dev/null
>
> But in python that does not work using the os.system() function, that is:
> os.system("echo 'blabla=2*bla' | r.mapcalc &> /dev/null")
>
> Anyone has any tips on the matter?
>
> Thanks
> Daniel
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>


More information about the grass-user mailing list