[GRASS-user] script in python

Gabriele Nolè gis.gn at libero.it
Mon Dec 1 09:23:49 EST 2008


Hi Jose.	
I changed the code by trying different solutions, such as:
------------------------------------------------------------------------------------------
def main():
	vect1 = options['vect_1']
	vect2 = options['vect_2']
	vect3 = options['vect_3']
	
       
vbuffer=subprocess.Popen('v.buffer','input=vect_1','output=buffer_200m','buffer=200')
	retcode=vbuffer.wait()  
	 
      # Then I also tried with another command (v.db.addcol):
      #import subprocess
     
#vaddcol=subprocess.Popen('v.db.addcol','map=vect_1','columns=prova','VARCHAR(15)')
      #retcode=vaddcol.wait() 	
        
if __name__ == "__main__":
	options, flags = grass.parser()
	main()
-----------------------------------------------------------------------------	
but I have a mistake in any event:

Traceback (most recent call last):
  File "/home/gab/scripts_grass/v.rischio_incendi.py", line
81, in <module>
    main()
  File "/home/gab/scripts_grass/v.rischio_incendi.py", line
75, in main
    vaddcol=subprocess.Popen('v.db.addcol','map=vect_1','col
umns=prova','VARCHAR(15)')
  File "/usr/lib/python2.5/subprocess.py", line 545, in
__init__
    raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer

Con You suggest me what links to study?

Thank you very much
Ciao

Gabriele


Jose A. Ruiz-Arias wrote:
> 
> Hi Gabriele,
> 
> I suggest to try
> 
> grass.run_command('v.buffer','input = vect_1','output = 
> buffer_200m','buffer= 200')
> 
> assuming that grass.run_command is a wrapper to subprocess.popen or so.
> Specifically, you could try
> 
> import subprocess
> vbuffer=subprocess.Popen('v.buffer', 'input=vect_1', 
> 'output=buffer_200m', 'buffer=200')
> retcode=vbuffer.wait()
> 
> within the proper GRASS environment session. Read Python's Reference 
> Manual regarding subprocess
> 
> Cheers,
> Jose
> 
-- 
View this message in context: http://www.nabble.com/script-in-python-tp20758838p20772848.html
Sent from the Grass - Users mailing list archive at Nabble.com.



More information about the grass-user mailing list