Skip to main content

a simple subprocess manager,suport stream stdout \ async

Project description

### 介绍

一个subprocess模块的封装,可以更方便的进行系统调用

To Do List:
....

[开发processcall的环境是python3哦]

### 安装

pip安装
```
pip install processcall
```

源码安装
```
git clone git@github.com:rfyiamcool/processcall.git
cd processcall
python setup.py install
```

### 使用方法

只单纯的执行,然后返回linux run code和执行状态

```
>>> import processcall
>>> r = processcall.run('uptime')
04:06:37 up 2 min, 1 user, load average: 0.20, 0.19, 0.08
>>> r.output
>>> r.success
True
>>> r.retcode
0
```

捕捉所有的执行结果
```
>>> r = processcall.run_capture('uptime')
>>> r.output
' 04:07:16 up 2 min, 1 user, load average: 0.11, 0.17, 0.08\n'
>>> r.success
True
>>> r.retcode
0
```

把输出的结果精简过,maxlines是控制行数
```
print(run_capture_limited('ls', maxlines=2).output)
```

processcall example usage:

```
from processcall import run_capture

r = run_capture('ls -la')
if r.success:
print(r.output)
else:
print("Error: '%s' exit code %s" % (r.command, r.retcode))
print(" ...")
# print last three lines of output
for line in r.output.splitlines()[-3:]:
print(" %s" % line)
```

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

processcall-1.1.0.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file processcall-1.1.0.tar.gz.

File metadata

  • Download URL: processcall-1.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for processcall-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2a4dc6b5d58ce31fe84c0167072a9aff91ca451d28c950115d6bb73d2ae33e9c
MD5 be9d561e1f73f19fa776cf581acfa71e
BLAKE2b-256 f82bde664152bc877e0ebe9ee5c3826de3dafc7969672ec12e45f31ef6435fda

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