Skip to main content

A library for running shell pipelines using shell-like syntax

Project description

This is an alpha release. The library may be changed completely or even may be thrown away. Comments are welcome.

Facts

  • Enables piping infinite streams through shell pipelines in Python

  • Uses standard modules subprocess, threading

  • Allows doing things marked as red warning boxes at the subprocess help page

  • 0.2 KLOC, tests included

Basic Usage

Pipe 100 000 lines through wc -l and join the resulting iterable into a single string:

>>> from iterpipes import pipe, runpipe
>>> wc = pipe('wc -l')
>>> ''.join(wc('%d\n' % i for i in xrange(100000)))
'100000\n'

Total lines in *.py files under the directory /path/to/dir, use safe shell parameters formatting:

>>> runpipe(
...     'find {} -name {} -print0 | xargs -0 wc -l | tail -1 | awk {}',
...     '/path/to/dir', '\*.py', '{print $1}')
'147\n'

Just format a string using correct shell escaping:

>>> from iterpipes import format
>>> format('find {} -name {}',
...     ['/home/path with spaces', 'not a shell wildcard.\*'])
'find /home/path\\ with\\ spaces -name not\\ a\\ shell\\ wildcard.\\*'

Download

This is not really a release. Clone the iterpipes repository if you are interested in following the library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iterpipes-0.2.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page