*Glynn Clements* wrote:
Check the exit code from the command. Commands should use a non-zero
exit code if there was an error.
It would help to know exactly how the command is being run.
Hi,
You are absolutely right 
Among others, I'm using:
grass.run_command("r.in.gdal", flags= 'k', overwrite = 'o', input = src_file, output = target_file)
Shall I do something like
check_process=grass.run_command("r.in.gdal", flags= 'k', overwrite = 'o', input = src_file, output = target_file) if check_process=0:
gdal_fatal (_("ERROR"))
?
Thanks
Antonio
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5534 (20101015) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
Hi,
2010/10/15 António Rocha <antonio.rocha@deimos.com.pt>:
check_process=grass.run_command("r.in.gdal", flags= 'k', overwrite = 'o',
input = src_file, output = target_file) if check_process=0:
gdal_fatal (_("ERROR"))
no, '0' means success, non-zero code is usually used for failure. Also
use '==' in conditions, so
ret = grass.run_command(...)
if ret != 0:
grass.fatal('error')
Martin
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
[keep discussion in ML]
2010/10/15 António Rocha <antonio.rocha@deimos.com.pt>:
Thanks... You are right Zero is for success.
By the way, if a GRASS gunction, that I'm using through grass.run_command
is, prints something in Command Output, how can I "get" it in order to use
it?
try grass.read_command [1].
Martin
[1] http://grass.osgeo.org/programming7/namespacegrass_1_1script_1_1core.html#a7cf2b8f9c0c14e2e9c23acdfe9178433
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
António Rocha wrote:
> Check the exit code from the command. Commands should use a non-zero
> exit code if there was an error.
>
> It would help to know exactly how the command is being run.
>
>
Hi,
You are absolutely right 
Among others, I'm using:
grass.run_command("r.in.gdal", flags= 'k', overwrite = 'o', input = src_file, output = target_file)
if grass.run_command(...) != 0:
grass.fatal(...)
run_command and write_command return the exit code.
start_command, pipe_command, and feed_command return the Popen object;
you can check its .returncode attribute once it has terminated.
read_command and parse_command return the data written to the child's
stdout; there isn't any mechanism to retrieve the exit status for
these. OTOH, read_command is trivial to implement yourself if you need
this.
--
Glynn Clements <glynn@gclements.plus.com>