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 details)

Uploaded Source

File details

Details for the file iterpipes-0.2.tar.gz.

File metadata

  • Download URL: iterpipes-0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for iterpipes-0.2.tar.gz
Algorithm Hash digest
SHA256 2670d41c141d091e34428f037f0522ecd48481d9b494607bcc96b9dafca5f834
MD5 f8385d0d4d19e95cc0c08cdf5ab4aeab
BLAKE2b-256 e06c7b0e1668dfc84ffd407bfa9a1277b09b134048fde06f0ed90c6395f11351

See more details on using hashes here.

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