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": {
"uuid": "fedcba09-1234-1111-bcde-1234567890fe"
}
}
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.3.tar.gz
(4.2 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.3.tar.gz.
File metadata
- Download URL: taskcapsule-0.1.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24a6394ceaa35f86984456e02ec8d1ca4b192533a53007ce2543c2b477548bcf
|
|
| MD5 |
d6fd66131973b4b717b734bfd0a5d4b4
|
|
| BLAKE2b-256 |
28045d7f87e166fbb1606dbf9ce9bd51084bc4a7e76f1e87210b95d8fc356ebf
|
File details
Details for the file taskcapsule-0.1.3-py3-none-any.whl.
File metadata
- Download URL: taskcapsule-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.5 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 |
4faa7a376033dd4298930f85c49ed8ff52859575bdd50310f46d5ff298b76a4e
|
|
| MD5 |
82c664f838b48caef256f69125a740e5
|
|
| BLAKE2b-256 |
506c45eff24548df381f62642eee52848f1a263a9994c875e17cb62d7ca1808a
|