-
Notifications
You must be signed in to change notification settings - Fork 197
run.command(): Support for command-line piping #1392
Description
When the Python script library was first provided, piping in/out of image data actually worked just as it does for binary executables; this was due to the use of shell=True in the run.command() function. This capability was revoked as this function became more advanced; this however now prevents the use of piped images as the input / output of Python scripts.
To restore support for this will require some gymnastics:
-
Command-line arguments will need to have a flag indicating if they are an input or an output image, much like the
.type_*()C++ functions. -
The
appmodule will need to replace the value of any '-' input image argument with the contents ofstdin. Therun.command()function could either just display this, or replace any appearances of temporary image paths with '-'.
This I think would be easier than trying to detect the '-' withinrun.command()(where information about whether it's an input or output would have been lost) and connect the processes'sstdinto that of the main process. -
The
run.command()function will need to be informed if the command call includes an output to a pipe, and store the contents ofstdoutfrom that call somewhere for theappmodule to write tostdoutof the main process.
This can't strictly be done based on the "last"run.command()call, since a script may contain multiple outputs and an output piped image may not necessarily appear as part of the very last one.