The official Python SDK for Task Badger
Project description
Task Badger Python Client
This is the official Python SDK for Task Badger.
For full documentation go to https://docs.taskbadger.net/python/.
Getting Started
Install
pip install --upgrade taskbadger
Client Usage
Configuration
import taskbadger
taskbadger.init(
organization_slug="my-org",
project_slug="my-project",
token="***"
)
Usage with Celery
import taskbadger
from celery import Celery
app = Celery("tasks")
@app.task(bind=True, base=taskbadger.Task)
def my_task(self):
task = self.taskbadger_task
for i in range(1000):
do_something(i)
if i % 100 == 0:
task.update(value=i, value_max=1000)
task.success(value=1000)
API Example
from taskbadger import Task, Action, EmailIntegration, WebhookIntegration
# create a new task with custom data and an action definition
task = Task.create(
"task name",
data={
"custom": "data"
},
actions=[
Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")),
Action("cancelled", integration=WebhookIntegration(id="webhook:demo")),
]
)
# update the task status to 'processing' and set the value to 0
task.started()
try:
for i in range(100):
do_something(i)
if i!= 0 and i % 10 == 0:
# update the progress of the task
task.update_progress(i)
except Exception as e:
# record task errors
task.error(data={
"error": str(e)
})
raise
# record task success
task.success()
CLI USage
Configuration
$ taskbadger configure
Organization slug: my-org
Project slug: project-x
API Key: XYZ.ABC
Config written to ~/.config/taskbadger/config
Usage Examples
The CLI run command executes your command whilst creating and updating a Task Badger task.
$ taskbadger run "demo task" --action error email to:me@test.com -- path/to/script.sh
Task created: https://taskbadger.net/public/tasks/xyz/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
taskbadger-1.2.0.tar.gz
(30.1 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 taskbadger-1.2.0.tar.gz.
File metadata
- Download URL: taskbadger-1.2.0.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032b2bed73e284fcd44cfed4ac40b154ae133e12435666f96446d956e8132365
|
|
| MD5 |
6f8d50157cdf86c0ed7172f41089a2eb
|
|
| BLAKE2b-256 |
a6a1444312b618a39c345a23f3ddcf9789d1eb6219205e325002001b6dffb15f
|
File details
Details for the file taskbadger-1.2.0-py3-none-any.whl.
File metadata
- Download URL: taskbadger-1.2.0-py3-none-any.whl
- Upload date:
- Size: 57.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a62c2198136c74c451b5dd74da19bd6baceb82927420fe87f08c130e983b2c57
|
|
| MD5 |
b838276626ad2751d82724f94908dc04
|
|
| BLAKE2b-256 |
dc7c6be761028ce39165ce41c7f5ddaa82022ecfef04f68d0daa845255523977
|