An extensible, asyncio interface to subprocesses, plus a set of wrappers around common system tools that works well with yaclipy
Project description
yaclipy-tools
An extensible, asyncio interface to subprocesses, plus a set of wrappers around common system tools that works well with yaclipy
Tools
- curl
- docker
- ffmpeg
- firebase
- gcloud
- git
- gpg
- graphviz
- grep
- kubectl
- md5
- nginx
- openssl
- shasum
The set of tools can easily be extended by subclassing SysTool
ProcTask
This creates an asynchronous connection to a sub-process. It is based upon loop.subprocess_exec().
await ProcTask('diff', 'README.md', 'README.md') 0
For more complicated interactions, plugins are used.
await ProcTask.using(Lines(1))('ls', '-al') [...]
The Lines plugin captured stdout (1) and return a list of lines. If no plugins want to return a value then the default behavior is to return the returncode as seen in the above example. If multiple plugins want to return a value then they are returned as a tuple:
await ProcTask.using(Lines, Lines(2))('ls', '-al') ([...], [...])
The first value of the tuple contains the lines from stdout AND stderr, whereas the second list only contains stderr lines.
Echo
The Echo plugin prints to the print_ext Printer(). By setting the context you can create nice, grouped command output.
Lines
Capture the output and return a list of strings
OneLine
Capture the output but only return one of the lines
Input
Send data to stdin of the process
Log
Capture the output and send it to a file (or other io.Stream)
Watch
Ask for the output to be captured so that you can use it asynchronously.
SysTool
SysTool build upon ProcTask by integrating it with yaclipy and adding more user-facing features, such as:
- configurable command location (no more environment variables)
- Tool availability and version check.
- Helpful info about how to install missing tools.
Table of Contents
Installation
pip install yaclipy-tools
License
yaclipy-tools
is distributed under the terms of the MIT license.
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
Built Distribution
Hashes for yaclipy_tools-0.10.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ced6fd76bb772e8c0f5ff41648b4baf4b899c6ffec4f47eb9668cc55350c62b |
|
MD5 | c412b9623a0594ab011189e545497114 |
|
BLAKE2b-256 | 253dbc4450d9dcdaf900b4f9931ee3bff21b4301cd96f9f94a74d2e1b122f5da |