https://github.com/rec/sproc
⛏ Subprocesses for subhumanses ⛏
https://github.com/rec/sproc
python subprocess tools
Last synced: 9 months ago
JSON representation
⛏ Subprocesses for subhumanses ⛏
- Host: GitHub
- URL: https://github.com/rec/sproc
- Owner: rec
- License: mit
- Created: 2020-02-29T16:29:48.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T14:42:28.000Z (almost 2 years ago)
- Last Synced: 2025-03-24T04:04:05.185Z (10 months ago)
- Topics: python, subprocess, tools
- Language: Python
- Homepage: https://rec.github.io/sproc/
- Size: 676 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELIST
- Funding: FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ⛏️sproc: subprocesseses for subhumanses ⛏
Run a command in a subprocess and yield lines of text from `stdout` and
`stderr` independently.
Useful for handling long-running proceesses that write to both `stdout` and
`stderr`.
### Simple Example
import sproc
CMD = 'my-unix-command "My Cool File.txt" No-file.txt'
for ok, line in sproc.Sub(CMD) as sp:
if ok:
print(' ', line)
else:
print('!', line)
if sp.returncode:
print('Error code', sp.returncode)
# Return two lists of text lines and a returncode
out_lines, err_lines, returncode = sproc.run(CMD)
# Call callback functions with lines of text read from stdout and stderr
returncode = sproc.call(CMD, save_results, print_errors)
# Log stdout and stderr, with prefixes
returncode = sproc.log(CMD)
### [API Documentation](https://rec.github.io/sproc#sproc--api-documentation)