A simple task runner for Python
Project description
taskcapsule
A simple framework for running commands in parallel using templated commands and dictionaries of arguments.
Example
from taskcapsule import TaskRunner, Task
# Look to see if the host is running WebLogic T3
template = "nmap -oG - -p {port} --script weblogic-t3-info {addr}"
items = {"addr":"1.2.3.4","port": "7002"}
my_tasks = []
for i in items:
kwargs = items
my_tasks.append(
Task(
command=template,
kwargs=kwargs,
target_metadata={"uuid": "fedcba09-1234-1111-bcde-1234567890fe"},
# This is in the output if, and only if, T3 is running
output_filter="T3",
)
)
tr = TaskRunner(tasks=my_tasks)
tr.run()
Output
python example.py|jq
INFO:taskcapsule:spawning 1 workers
{
"command": "nmap -oG - -p 7002 --script weblogic-t3-info 1.2.3.4",
"kwargs": {
"addr": "1.2.3.4",
"port": "7002"
},
"return_code": 0,
"stdout": "# Nmap 7.95 scan initiated Thu Apr 17 09:23:50 2025 as: nmap -oG - -p 7002 --script weblogic-t3-info 1.2.3.4\nHost: 1.2.3.4 ()\tStatus: Up\nHost: 45.60.186.97 ()\tPorts: 7002/open/tcp//afs3-prserver//WebLogic application server 12.2.1.4 (T3 enabled)/\n# Nmap done at Thu Apr 17 09:23:51 2025 -- 1 IP address (1 host up) scanned in 0.70 seconds\n",
"stderr": "",
"duration": 0.7490861415863037,
"success_filter": "T3",
"target_metadata": {
"entity_id": ""
}
}
INFO:task-runner:all tasks completed
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
taskcapsule-0.1.0.tar.gz
(4.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taskcapsule-0.1.0.tar.gz.
File metadata
- Download URL: taskcapsule-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb281e32751c31d935299366c4b2ffcfa010b2ba1665fb2e2eb06ed977ea4334
|
|
| MD5 |
0a74d8cc0879a355b01564dc288d132f
|
|
| BLAKE2b-256 |
b3e21741000fd8614aace7d4d7b2cb59346d8aa36a35d45e3cefe37f584d3222
|
File details
Details for the file taskcapsule-0.1.0-py3-none-any.whl.
File metadata
- Download URL: taskcapsule-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ea12e63faffdec8f284bc28dbfb9c399cd5a55db4cafcd91184485fdd0f8cc1
|
|
| MD5 |
72cbac248ef66a7a510be245b2ddefda
|
|
| BLAKE2b-256 |
55b5b3ba7ddfd060d8e92f385fb84679fd6acec28061d17d69e28c4d8c7c3522
|