popen_spawn - use pexpect with a piped subprocess — Pexpect 4.2.1 documentation

# popen_spawn - use pexpect with a piped subprocess

Provides an interface like pexpect.spawn interface using subprocess.Popen

## PopenSpawn class

class `pexpect.popen_spawn.` `PopenSpawn`(cmd, timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None, encoding=None, codec_errors='strict')
  `__init__`(cmd, timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None, encoding=None, codec_errors='strict')
  `send`(s)

    Send data to the subprocess’ stdin.

    Returns the number of bytes written.

  `sendline`(s='')

    Wraps send(), sending string `s` to child process, with os.linesep automatically appended. Returns number of bytes written.

  `write`(s)

    This is similar to send() except that there is no return value.

  `writelines`(sequence)

    This calls write() for each element in the sequence.

    The sequence can be any iterable object producing strings, typically a list of strings. This does not add line separators. There is no return value.

  `kill`(sig)

    Sends a Unix signal to the subprocess.

    Use constants from the `signal` module to specify which signal.

  `sendeof`()

    Closes the stdin pipe from the writing end.

  `wait`()

    Wait for the subprocess to finish.

    Returns the exit code.

  `expect`()
  `expect_exact`()
  `expect_list`()

    As `pexpect.spawn`.