datalad_next.shell.ShellCommandResponseGenerator

class datalad_next.shell.ShellCommandResponseGenerator(stdout_gen: Generator, stderr_deque: deque)[source]

Bases: Generator

An abstract class the specifies the minimal functionality of a response generator

Subclasses of this class can be used to implement operation-specific, shell-specific or OS-specific details of the command execution and the command output parsing.

The return code is available in the returncode-attribute, the stderr-output is available in the stderr_deque-attribute (a deque-instance), of instances of this class.

abstract get_final_command(command: bytes) bytes[source]

Return a final command list that executes command

This method should return a "final" command-pipeline that executes command and generates the output structure that the response generator expects. This structure will typically be parsed in the implementation of send().

This method is usually only called by ShellCommandExecutor.__call__().

abstract send(_) bytes[source]

Deliver the next part of generated output

Whenever the response generator is iterated over, this method is called and should deliver the next part of the command output or raise StopIteration if the command has finished.

throw(typ, val=Ellipsis, tb=Ellipsis)[source]

Raise an exception in the generator. Return next yielded value or raise StopIteration.