Skip to content

run.command(): Support for command-line piping #1392

@Lestropie

Description

@Lestropie

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:

  1. 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.

  2. The app module will need to replace the value of any '-' input image argument with the contents of stdin. The run.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 '-' within run.command() (where information about whether it's an input or output would have been lost) and connect the processes's stdin to that of the main process.

  3. The run.command() function will need to be informed if the command call includes an output to a pipe, and store the contents of stdout from that call somewhere for the app module to write to stdout of 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions