Skip to main content

Make shell script running in a Pythonic way.

Project description

About

Running shell in a Pythonic way.

Installation

$ pip install simplerun

Usage

Basic

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

0 refers 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

Iterable as input data

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

Result object as input data

>> r_data = run('ps aux')
>> r = 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`>]

review history, and keep going with good input:

>> r.rest
[['grep', 'keyword']]
>>
>> r2 = run(r.rest, '''Good line that contains the keyword,
                       but not this line, sorry.''')
>> print(r2.std_out)
'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.3.tar.gz (3.0 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for simplerun-0.3.tar.gz
Algorithm Hash digest
SHA256 293f0195fd63b5611c83aca29d7893e668802737c296daee2fff5f6ea7c53251
MD5 70fda93a9de963e220a8355cdc3a0491
BLAKE2b-256 23592faddc359fbe92285c677dd8e8b6d9262f0167ee8f91d959badbd974d39f

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