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.2.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.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: taskcapsule-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ec445b5fa75e680db7f7fa6cbfc43e667bf0a2e918d5dd0c46f785abc6141b09
MD5 91e5f908dfea33761cd8dd80e9b977da
BLAKE2b-256 8f11bafbf453c57104bbaa1a6c1200a5c13ddfba3cd5dec71246e34c892fa6e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: taskcapsule-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 67409d10d86f412a89dbae71c63eb94501e02788d49e3ca9f6ca6a2c959844bd
MD5 1974366bc7a086eed66c64528c7a57c2
BLAKE2b-256 df6346267fb998ddb0bed703d51327ff8154d663fe7bc1e8116a519d972e8630

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