[Biopython-dev] ApplicationResult and generic_run obsolete?

Peter biopython at maubp.freeserve.co.uk
Tue Aug 4 19:29:47 UTC 2009


On Thu, Jul 9, 2009 at 10:18 AM, Peter<biopython at maubp.freeserve.co.uk> wrote:
> On Wed, Jul 8, 2009 at 2:06 PM, Brad Chapman<chapmanb at 50mail.com> wrote:
>> How about adding a function like "run_arguments" to the
>> commandlines that returns the commandline as a list.
>
> That would be a simple alternative to my vague idea "Maybe we
> can make the command line wrapper object more list like to make
> subprocess happy without needing to create a string?", which may
> not be possible. Either way, this will require a bit of work on the
> Bio.Application parameter objects...

By defining an __iter__ method, we can make the Biopython
application wrapper object sufficiently list-like that it can be
passed directly to subprocess. I think I have something working
(only tested on Linux so far), at least for the case where none
of the arguments have spaces or quotes in them.

If this works, it should make things a little easier in that we don't
have to do str(cline), and also I think it avoids the OS specific
behaviour of the shell argument as Brad noted earlier:

>> This avoids the shell nastiness with the argument list, is as
>> simple as it gets with subprocess, and gives users an easy
>> path to getting stdout, stderr and the return codes.

i.e. I am hoping we can replace this:

child = subprocess.Popen(str(cline), shell(sys.platform!="win32"), ...)

with just:

child = subprocess.Popen(cline, ...)

where the "..." represents any messing about with stdin, stdout
and stderr.

Peter



More information about the Biopython-dev mailing list