On 06/03/12 11:42, Johannes Radinger wrote:
Hi,

I try to run a python script including the r.reclass command with stdin.
I am running GRASS 6.5.svn50782M (2012) on a Mac OSX. The part of the script is:

        grass.run_command("r.reclass",
                                        input = "Treene_tmp_mask1",
                                        rules = "-",
                                        stdin = '1 thru 999 = 1 1',
                                        output = "Treene_mask_2")

and the error:
Traceback (most recent call last):
   File "/Users/Johannes Radinger/Desktop/SDM_V2R.py", line
92, in<module>
     sys.exit(main())
   File "/Users/Johannes Radinger/Desktop/SDM_V2R.py", line
68, in main
     output = "Treene_mask_2")
   File "/Applications/GRASS-6.5.app/Contents/MacOS/etc/pytho
n/grass/script/core.py", line 189, in run_command
     ps = start_command(*args, **kwargs)
   File "/Applications/GRASS-6.5.app/Contents/MacOS/etc/pytho
n/grass/script/core.py", line 177, in start_command
     return Popen(args, **popts)
   File "/Applications/GRASS-6.5.app/Contents/MacOS/etc/pytho
n/grass/script/core.py", line 56, in __init__
     startupinfo, creationflags)
   File "/Library/Frameworks/Python.framework/Versions/2.6/li
b/python2.6/subprocess.py", line 616, in __init__
     errread, errwrite) = self._get_handles(stdin, stdout,
stderr)
   File "/Library/Frameworks/Python.framework/Versions/2.6/li
b/python2.6/subprocess.py", line 973, in _get_handles
     p2cread = stdin.fileno()
AttributeError: 'str' object has no attribute 'fileno'


What I am doing wrong or is there a bug in the code?

You have to use grass.write_command to be able to use stdin.

Moritz
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to