Skip to main content

Make shell script running in a Pythonic way.

Project description

Installation

pip install simplerun or python setup.py install

Usage

Basic usage:

>>> import simplerun
>>> r = simplerun.run('ls -l')
>>> r
<[0] `ls -l`>

0 refer to the exit code here.

>>> print r.std_out
total 8
-rw-r--r-- 1 yj staff 664 11 19 21:46 README.md
-rw-r--r-- 1 yj staff 829 11 18 22:39 setup.py
drwxr-xr-x 6 yj staff 204 11 19 21:46 simplerun

Use iterable as input data:

>>> with open('simplerun.py') as f:
>>>     r = simplerun.run('grep def', f)
>>>     print r.std_out

Use Result as input data:

>>> r_data = simplerun.run('ps aux')
>>> r = simplerun.run('grep Chrome', r_data)

Use as a debugger:

>>> r = run('ps aux | stranger | grep keyword')
>>> r
<[-1] `stranger`>
>>> r.exc
OSError(2, 'No such file or directory')

Found the stanger is the evil

>>> r.history
[<[0] `ps aux`>]

Show history, and run it again with good input

>>> r.rest
[['grep', 'keyword']]
>>>
>>> r2 = run(r.rest, '''This is the good line that contains the keyword,
                        but not this line, sorry.''')
>>> r2
<[0] `grep keyword`>
>>> print r2.std_out,
'This is a good line that contains the keyword\n'

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

simplerun-0.2.tar.gz (1.9 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for simplerun-0.2.tar.gz
Algorithm Hash digest
SHA256 9537a56cea2a77ea1eb1f1707e0a638eaca1e524b6d6ad431418f745ecc33026
MD5 28d7701a71958bd9f7e9bbd86e93ab7d
BLAKE2b-256 890c17425057ce42b616d43feae3cfdb8dc98551cc679d822480813b97b42314

See more details on using hashes here.

Supported by

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