[GRASSGUI] initiating d.* command dialogs with existing parameters

Glynn Clements glynn at gclements.plus.com
Sun Mar 25 12:41:01 EDT 2007


Michael Barton wrote:

> I can't remember the exact error, but it said essentially that "PIPE" is not
> a valid parameter. This could be a bug in the Mac version, of course. But it
> would be nice to see if it works on another platform before I report it, in
> case I've just forgotten some punctuation, capitalization, or something.

You either need to use subprocess.PIPE, or change "import subprocess"
to "from subprocess import *". If you take the latter approach, you
need to remove the "subprocess." prefix from subprocess.call,
subprocess.Popen etc.

The "import <module>" syntax requires you to use qualified names,
while "from <module> import *" allows you to use unqualified names.

Alternatively, you can import specific identifiers, e.g.:

	from subprocess import (call, Popen, PIPE, STDOUT)

In any case, the call:

            self.out = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT).communicate()[0]

seems to work once the relevant identifiers have been imported.

BTW, GMConsole.runCmd() currently executes the command twice; once
with call(), and again with os.popen().

Also, I had to remove an "import images" statement from wxgui.py; that
module doesn't appear to exist.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-gui mailing list