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.3.4.tar.gz
(30.7 kB
view details)
Built Distribution
File details
Details for the file taskbadger-1.3.4.tar.gz
.
File metadata
- Download URL: taskbadger-1.3.4.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59895a4d2f176d79abf58a7439d97b9112bcd4dad3f58d50a94189c1a79c7609 |
|
MD5 | 0a1a0d716c7124be2d25bb6b4544bf9b |
|
BLAKE2b-256 | 139295a3e5ba03fb7fe553bfdb0bc98e3d60708866c7f2dde04ae4efd7ea16ab |
File details
Details for the file taskbadger-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: taskbadger-1.3.4-py3-none-any.whl
- Upload date:
- Size: 57.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7d5309ac52e2e07ed576fb2aee3790817716e25acc94e4037607cd372262ac |
|
MD5 | 380d7d5cc1c32346074ac21b4f5f37fb |
|
BLAKE2b-256 | 18f722ece8dabb5348a250fcbf37dca4ea7fd22e6c4b162c8962ad50bd2bb16a |