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": {
    "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.1.tar.gz (4.2 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.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: taskcapsule-0.1.1.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

Hashes for taskcapsule-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f51b5e1560ab29d10a21dfa550807b951b5d53b7ebb5150555d57e42efcd6aa1
MD5 f9cd277b30b2e74bf67621c6df6c102a
BLAKE2b-256 296ba84c741ce3e9290cd080111db1210260192bf1d3d1ffcc15e5df09d27309

See more details on using hashes here.

File details

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

File metadata

  • Download URL: taskcapsule-0.1.1-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

Hashes for taskcapsule-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41a2c23164bfa826ab6edea1e906c1a0c22eb0aa1060fe5719ea7f2d26b185c7
MD5 96df9ad6b641d663c64f2a9172bba76b
BLAKE2b-256 4b368f6cd415eaacd43bec0cc1c82346dd72bac9d93ef0d54dcee640c724d1cf

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