Search code examples
pythonpython-envoy

`envoy`-like abstraction of subprocess


I was really excited about the Envoy project when I first heard about it. Having a sane API for subprocess is something I very much need.

However, envoy seems not to be maintained anymore. The last commit was made 10 months ago, and the last release was made 2 years ago. There are a bunch of serious bugs in it that I reported a long time ago, but were not fixed.

I'm looking for an alternative. Does anyone know of a Python package that does the same thing as Envoy (gives a good API to subprocess), except it's actively maintained?


Solution

  • There is the sarge package, available with: pip install sarge

    It is documented here: http://sarge.readthedocs.org/en/latest/tutorial.html#installation-and-testing

    It seems to be actively maintained & the maintainer is a frequent user of stack overflow (see one of their posts on the topic here: https://stackoverflow.com/a/11032170/2942522 )

    A snippet from the sarge docs & one of the usage examples provided:

    "If you want to interact with external programs from your Python applications, Sarge is a library which is intended to make your life easier than using the subprocess module in Python’s standard library."

    >>> from sarge import run, Capture
    >>> p = run('echo foo; echo bar; echo baz', stdout=Capture())
    >>> p.stdout.readline()
    'foo\n'
    >>> p.stdout.readline()
    'bar\n'
    >>> p.stdout.readline()
    'baz\n'
    >>> p.stdout.readline()
    ''