prey
#!/usr/bin/env prey
async def main():
await x("cat pyproject.toml | grep name")
branch = await x("git branch --show-current")
await x(f"dep deploy --branch={branch}")
await x(
[
"sleep 1; echo 1",
"sleep 2; echo 2",
"sleep 3; echo 3",
]
)
name = "foo bar"
await x(f"mkdir /tmp/${name}")
A tool for writing shell scripts in Python. Inspired by google/zx. This package provides a wrapper around asyncio.subprocess. If you're looking for a more complete solution you may want to check out zxpy.
Install
pip install prey
Documentation
Wrap your scripts in an async function called main:
async def main():
# script...
It must be called main as the executable looks for a function calls main and calls it. This is used so commands can be asynchronous.
You can add the shebang at the top of your script:
#!/usr/bin/env prey
and run it like so:
chmod +x ./script.py
./script.py
Or via the prey executable:
prey ./script.py
When using prey via the executable or a shebang, all of the functions (x, colorama, request, etc) are available wihtout any imports.
await x("command")
Asychronously executes a given string using the create_subprocess_shell function from the asyncio.subprocess module and returns the output.
count = int(await x("ls -1 | wc -l"))
print(f"Files count: {count}")
cd("filepath")
Changes the current working directory.
cd("/tmp")
await x('pwd') # outputs /tmp
colorama package
The colorama package is available without importing inside scripts.
print(f"{colorama.Fore.BLUE}Hello World!")
request package
A wrapper around aiohttp, aiohttp-requests.requests.session.request, is available without importing inside scripts.
response = await request("get", "http://python.org")
html = await response.text()
Importing from other scripts
It is possible to make use of x and other functions via explicit imports:
#!/usr/bin/env prey
from prey import x
await x('date')
Passing env variables
os.environ["FOO"] = "bar"
await x('echo $FOO')
Metadata
Release files for prey 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prey-0.1.4.tar.gz | 4.0 kB | Without provenance | Details for prey-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prey-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for prey-0.1.4-py3-none-any.whl |
Total release size: 8.1 kB
Release files / prey-0.1.4.tar.gz
| Download URL | prey-0.1.4.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cbf262a861755f1dbee4433e2af857b0a449cc25cacb790635daa2728f2e005
|
|
BLAKE2b-256 checksum How to use checksums |
9fe8d7994dd71197b5967bd01b6509471e58911fbf26515c9a4d3e119a3cd3d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-55-generic
|
Release files / prey-0.1.4-py3-none-any.whl
| Download URL | prey-0.1.4-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44f05f079e02e61e9dcc97272715db4dc6a5bf7637bd3e979ae4007945c241e0
|
|
BLAKE2b-256 checksum How to use checksums |
40a5f5115ea1abfbf008271455c9aba4c2ccca0e0e96c626602b3a5f0b0833b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-55-generic
|
Security for prey 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.