Allows to execute subprocess commands and get their output in real-time.
Project description
B.ContinuousSubprocess
A helper package that lets you execute long running processes and continuously receive their output.
Description
Imagine you want to programmatically run a command that lists objects
in a given directory. The command subprocess.call('ls')
will do the
trick quite conveniently. However, the same approach to long running
commands like cdk deploy *
or pytest -s
or ls / -R
is not very
convenient as you get the whole output only when the process finishes.
This package solves this inconvenience by outputting data in real-time
as the process runs.
Remarks
Biomapas aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. This is an open source library intended to be used by anyone. Improvements and pull requests are welcome.
Related technology
- Python 3
- Python subprocess Popen
- OS processes
Assumptions
The project assumes the following:
- You have basic knowledge in python programming.
- You have basic knowledge in OS processes.
Useful sources
-
Read more about python subprocess:
https://docs.python.org/3/library/subprocess.html. -
Read more about python subprocess "Popen" specifically:
https://docs.python.org/3/library/subprocess.html#popen-objects
Install
The project is built and uploaded to PyPi. Install it by using pip.
pip install b-continuous-subprocess
Or directly install it through source.
pip install .
Usage & Examples
The library is extremely easy to use. Simply create an instance of
ContinuousSubprocess
and execute it to get a generator. Then iterate
through the generator to receive your process output in real time.
from b_continuous_subprocess.continuous_subprocess import ContinuousSubprocess
command = str('cdk deploy *')
generator = ContinuousSubprocess(command).execute()
for data in generator:
print(data)
Testing
The project has tests that can be run. These are mostly simple tests that can be run out-of-the-box.
Run tests from a root directory with pytest
python testing library:
pytest
The tests usually take less than a few seconds to complete.
Contribution
Found a bug? Want to add or suggest a new feature?
Contributions of any kind are gladly welcome. You may contact us
directly, create a pull-request or an issue in github platform.
Lets modernize the world together.
Release history
0.1.0
- Add ability to kill a process.
0.0.3
- Start using Pylint.
- Start using Black.
0.0.2
- Finalize pipelines.
- Finalize project structure and naming.
0.0.1
- Initial build.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for b_continuous_subprocess-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | db9104188cbda8ca8c5c2647e3f1914bb3d34b99de7d95e972447f0fa589cb12 |
|
MD5 | 1c4ecbcc00a885ba5af87496e45f8d50 |
|
BLAKE2b-256 | d471b51f970354b135e254fa9234ebaac000c981c1726c1913757cb45444cca9 |
Hashes for b_continuous_subprocess-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c89c4d5436c84e1b115b65b80550774c84032c94bf2b7c73c9122c44017735c4 |
|
MD5 | 4971e6333b23f4abc1f3b835c426c6d8 |
|
BLAKE2b-256 | 124befc0e0517e0668f7abe1f006407df5db0e890808a985c0a8e38c83f722ed |