Check for the presence of prerequisite commands and returns their paths.
Project description
Overview
When you write a script or tool which uses subprocess to execute shell commands, you want to know if the commands are installed or not. This is particularly important if you are running multiple commands which rely on each other.
You can of course catch the exceptions through using check=True
but if you need to know they all exist before you start your execution run then
this doesn't help you as it only handled the failure it currently has.
This little package assist with that problem by taking a list of commands that must be installed and available and verifies that list at the start to ensure all of them are available.
Installation
pip install wolfsoftware.prereqs
Usage
import sys
from wolfsoftware.prereqs import check_prerequisite, PrerequisiteCheckError
prerequisites: list[str] = ["python", "git"]
try:
command_paths: dict = check_prerequisite(prerequisites)
except PrerequisiteCheckError as err:
print("Prerequisite check failed:")
for error in err.errors:
print(error)
sys.exit(0)
print(command_paths['python'])
Once the checks have completed, you now have a dict of commands and their associated paths which you can then utilise to ensure you are executing your subprocesses with the full path.
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
File details
Details for the file wolfsoftware_prereqs-0.1.4.tar.gz
.
File metadata
- Download URL: wolfsoftware_prereqs-0.1.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 195e8e8e109fbe7069d427af72e0e4ec9af084fe60a7a8c5425592c9e1d53041 |
|
MD5 | 9fe87f01eff43178b5fd511269bfa442 |
|
BLAKE2b-256 | 7e610444d369b7f59ea0870ba934a17bbbeac7aa5fe963378836432196131cfc |
File details
Details for the file wolfsoftware.prereqs-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: wolfsoftware.prereqs-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28d3d0ee6611d01c9d4368a147baaa6c1bac5caaf265dfd87cdf567163948c87 |
|
MD5 | b81f227a7ec93b5506bb6de1e2ad4b3e |
|
BLAKE2b-256 | 3bbb4430f700f62596b8aed08c9a4229714cc3ab196489f8f146f5143f5cb59f |