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

Glynn Clements glynn at gclements.plus.com
Sat Mar 24 23:12:58 EDT 2007


Michael Barton wrote:

> > If we're willing to accept a requirement of Python 2.4 or later, then
> > it appears that the subprocess module (the Popen class and the call
> > convenience function) is the preferred interface.
> > 
> > It seems to cover all of the required cases, doesn't use a shell
> > unless explicitly told to, and appears to implement all relevant
> > functionality on both Unix and Windows.
> 
> I'd tried to use Popen at one point (still commented out) in the command
> parser in gismutil.py. I never was able to get it to recognize the PIPE
> argument. I probably specified it wrong, but I could never find out how to
> get it right.

What do you mean by "recognize"?

The call looks okay, except that

            self.out = subprocess.Popen(cmd, shell=True, stdout=PIPE).stdout

is assigning a stream to self.out while the existing call:

            self.out = os.popen(cmd, "r").read()

is assigning a string. The former will cause the line:

            self.cmd_output.write(self.out+"\n")

to fail, as self.out won't be a string.

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




More information about the grass-gui mailing list