Greetings
I want to integrate in a Python script a call to an external binary (a small fucntion that I have done). What can i use to do this?
Thanks
Kat
Greetings
I want to integrate in a Python script a call to an external binary (a small fucntion that I have done). What can i use to do this?
Thanks
Kat
katrin eggert wrote:
I want to integrate in a Python script a call to an external binary (a small
fucntion that I have done). What can i use to do this?
The standard Python functions for spawning child processes are
subprocess.Popen() and subprocess.call()
http://docs.python.org/library/subprocess.html
The grass.script module has its own versions of these functions, which
set shell=True on Windows so that scripts work, but that doesn't
matter if you're running a binary executable. It also has several
functions which are intended specifically for running GRASS modules
(anything that uses the GRASS command-line parser).
--
Glynn Clements <glynn@gclements.plus.com>
Hello Glynn
Just one question: I reading http://grass.osgeo.org/programming6/pythonlib.html the "GRASS-oriented interface to subprocess module" and I’m wondering wich one of this functions shall i use to run an external bin in Windows? run_command?
Thanks
2011/7/1 Glynn Clements <glynn@gclements.plus.com>
katrin eggert wrote:
I want to integrate in a Python script a call to an external binary (a small
fucntion that I have done). What can i use to do this?The standard Python functions for spawning child processes are
subprocess.Popen() and subprocess.call()http://docs.python.org/library/subprocess.html
The grass.script module has its own versions of these functions, which
set shell=True on Windows so that scripts work, but that doesn’t
matter if you’re running a binary executable. It also has several
functions which are intended specifically for running GRASS modules
(anything that uses the GRASS command-line parser).–
Glynn Clements <glynn@gclements.plus.com>
katrin eggert wrote:
Just one question: I reading
http://grass.osgeo.org/programming6/pythonlib.html the "*GRASS-oriented
interface to subprocess module" and I'm wondering wich one of this functions
shall i use to run an external bin in Windows? run_command?*
Does the external program use the GRASS parser? If it doesn't, you
shouldn't use any of those functions; just use subprocess.Popen().
If it uses the parser, then the correct command to use depends upon
how you wish to interact with the child process. Read each of their
descriptions to determine which is appropriate.
All of them (except for exec_command) are simple wrappers around
start_command, which itself just uses make_command to construct a
suitable argument list to pass to Popen().
--
Glynn Clements <glynn@gclements.plus.com>
Hello
In this case is an external binary written in C. So I will shall use the subprocess.Popen() right?. Besides that general page you gave me, do you know any other page that explains, in a easier way, thje use and parameterizayion of subprocess.Popen()?
Thanks
Kat
2011/7/4 Glynn Clements <glynn@gclements.plus.com>
katrin eggert wrote:
Just one question: I reading
http://grass.osgeo.org/programming6/pythonlib.html the “*GRASS-oriented
interface to subprocess module” and I’m wondering wich one of this functionsshall i use to run an external bin in Windows? run_command?*
Does the external program use the GRASS parser? If it doesn’t, you
shouldn’t use any of those functions; just use subprocess.Popen().If it uses the parser, then the correct command to use depends upon
how you wish to interact with the child process. Read each of their
descriptions to determine which is appropriate.All of them (except for exec_command) are simple wrappers around
start_command, which itself just uses make_command to construct a
suitable argument list to pass to Popen().–
Glynn Clements <glynn@gclements.plus.com>
Not a very happy observation but did you look at the Subprocess manual
page on the Python web site? This is the main reference for the
module...
http://docs.python.org/library/subprocess.html
On Mon, Jul 4, 2011 at 6:29 PM, katrin eggert
<katrineggert1980@gmail.com> wrote:
Hello
In this case is an external binary written in C. So I will shall use the
subprocess.Popen() right?. Besides that general page you gave me, do you
know any other page that explains, in a easier way, thje use and
parameterizayion of subprocess.Popen()?
Thanks
Kat2011/7/4 Glynn Clements <glynn@gclements.plus.com>
katrin eggert wrote:
> Just one question: I reading
> http://grass.osgeo.org/programming6/pythonlib.html the "*GRASS-oriented
> interface to subprocess module" and I'm wondering wich one of this
> functions
> shall i use to run an external bin in Windows? run_command?*Does the external program use the GRASS parser? If it doesn't, you
shouldn't use any of those functions; just use subprocess.Popen().If it uses the parser, then the correct command to use depends upon
how you wish to interact with the child process. Read each of their
descriptions to determine which is appropriate.All of them (except for exec_command) are simple wrappers around
start_command, which itself just uses make_command to construct a
suitable argument list to pass to Popen().--
Glynn Clements <glynn@gclements.plus.com>_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
katrin eggert wrote:
Besides that general page you gave me, do you
know any other page that explains, in a easier way, thje use and
parameterizayion of subprocess.Popen()?
No.
--
Glynn Clements <glynn@gclements.plus.com>