@@ -13,97 +13,25 @@ For full documentation go to https://docs.taskbadger.net/python/.
1313### Install
1414
1515``` bash
16- pip install --upgrade taskbadger
16+ pip install taskbadger
1717```
1818
1919### Client Usage
2020
21- #### Configuration
22-
2321``` python
2422import taskbadger
23+ from taskbadger.systems import CelerySystemIntegration
2524
2625taskbadger.init(
27- organization_slug = " my-org " ,
28- project_slug = " my-project " ,
29- token = " *** "
26+ token = " *** " ,
27+ systems = [CelerySystemIntegration()] ,
28+ tags = { " environment " : " production " }
3029)
3130```
3231
33- #### Usage with Celery
34-
35- ``` python
36- import taskbadger
37- from celery import Celery
38-
39- app = Celery(" tasks" )
40-
41- @app.task (bind = True , base = taskbadger.Task)
42- def my_task (self ):
43- task = self .taskbadger_task
44- for i in range (1000 ):
45- do_something(i)
46- if i % 100 == 0 :
47- task.update(value = i, value_max = 1000 )
48- task.success(value = 1000 )
49- ```
50-
51- #### API Example
52-
53- ``` python
54- from taskbadger import Task, Action, EmailIntegration, WebhookIntegration
55-
56- # create a new task with custom data and an action definition
57- task = Task.create(
58- " task name" ,
59- data = {
60- " custom" : " data"
61- },
62- actions = [
63- Action(" */10%,success,error" , integration = EmailIntegration(to = " me@example.com" )),
64- Action(" cancelled" , integration = WebhookIntegration(id = " webhook:demo" )),
65- ]
66- )
67-
68- # update the task status to 'processing' and set the value to 0
69- task.started()
70- try :
71- for i in range (100 ):
72- do_something(i)
73- if i!= 0 and i % 10 == 0 :
74- # update the progress of the task
75- task.update_progress(i)
76- except Exception as e:
77- # record task errors
78- task.error(data = {
79- " error" : str (e)
80- })
81- raise
82-
83- # record task success
84- task.success()
85- ```
86-
87- ### CLI USage
88-
89- #### Configuration
90-
91- ``` shell
92- $ taskbadger configure
93-
94- Organization slug: my-org
95- Project slug: project-x
96- API Key: XYZ.ABC
97-
98- Config written to ~ /.config/taskbadger/config
99- ```
100-
101- #### Usage Examples
102-
103- The CLI ` run ` command executes your command whilst creating and updating a Task Badger task.
32+ ### CLI Usage
10433
10534``` shell
106- $ taskbadger run " demo task" --action error email to:me@test.com -- path/to/script.sh
107-
108- Task created: https://taskbadger.net/public/tasks/xyz/
35+ $ export TASKBADGER_API_KEY=***
36+ $ taskbadger run " nightly-backup" -- ./backup.sh
10937```
0 commit comments