Skip to main content

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.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskcapsule-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file taskcapsule-0.1.4.tar.gz.

File metadata

  • Download URL: taskcapsule-0.1.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for taskcapsule-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7f112f1a31201525d3148d7684429634b09d63c34faba0f12da6258dcc45cf95
MD5 6788f69997e7c76625306176b7e8edbd
BLAKE2b-256 ec356d8b970c84fa54ab41c9a1ef9c04f98020cb57abdb4536f9bb3cd26bcab9

See more details on using hashes here.

File details

Details for the file taskcapsule-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for taskcapsule-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 445bccd7f4edbfc573ee9be8205eb8eb651051798a5d3cf8a78093612a713b22
MD5 0910364e54d0069d782a30473c5e5b35
BLAKE2b-256 bd52b7622e6cb32aebd994b39fdc5668b942a46b71bf64b9d7ca8a3dc55790ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page