taskbadger 0.1__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {taskbadger-0.1 → taskbadger-0.2.1}/PKG-INFO +25 -5
- {taskbadger-0.1 → taskbadger-0.2.1}/README.md +7 -4
- {taskbadger-0.1 → taskbadger-0.2.1}/pyproject.toml +21 -1
- taskbadger-0.2.1/setup.py +43 -0
- taskbadger-0.2.1/taskbadger/__init__.py +3 -0
- taskbadger-0.2.1/taskbadger/internal/py.typed +1 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/sdk.py +121 -46
- taskbadger-0.1/setup.py +0 -43
- taskbadger-0.1/taskbadger/__init__.py +0 -2
- taskbadger-0.1/taskbadger/internal/py.typed +0 -1
- {taskbadger-0.1 → taskbadger-0.2.1}/LICENSE +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/cli.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/config.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/exceptions.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/integrations.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/__init__.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/__init__.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/__init__.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_cancel.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_create.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_get.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_list.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_partial_update.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_update.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/__init__.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_cancel.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_create.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_get.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_list.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_partial_update.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_update.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/client.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/errors.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/__init__.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/action.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/action_config.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/action_request.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/action_request_config.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/paginated_task_list.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/patched_action_request.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/patched_action_request_config.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/patched_task_request.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/patched_task_request_data.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/status_enum.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/task.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/task_data.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/task_request.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/task_request_data.py +0 -0
- {taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/types.py +0 -0
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: taskbadger
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: The official Python SDK for Task Badger
|
|
5
|
+
Home-page: https://taskbadger.net/
|
|
6
|
+
License: Apache-2.0
|
|
5
7
|
Requires-Python: >=3.8,<4.0
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
6
14
|
Classifier: Programming Language :: Python :: 3
|
|
7
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
8
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
9
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
10
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
11
26
|
Requires-Dist: attrs (>=21.3.0)
|
|
12
27
|
Requires-Dist: httpx (>=0.15.4,<0.24.0)
|
|
13
28
|
Requires-Dist: python-dateutil (>=2.8.0,<3.0.0)
|
|
14
29
|
Requires-Dist: tomlkit (>=0.11.6,<0.12.0)
|
|
15
30
|
Requires-Dist: typer[all] (>=0.7.0,<0.8.0)
|
|
31
|
+
Project-URL: Documentation, https://docs.taskbadger.net/
|
|
32
|
+
Project-URL: Repository, https://github.com/taskbadger/taskbadger-docs
|
|
16
33
|
Description-Content-Type: text/markdown
|
|
17
34
|
|
|
18
35
|
# Task Badger Python Client
|
|
19
|
-
|
|
36
|
+
|
|
37
|
+
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
38
|
+
|
|
39
|
+
For full documentation go to https://docs.taskbadger.net/python/.
|
|
20
40
|
|
|
21
41
|
---
|
|
22
42
|
|
|
@@ -59,12 +79,12 @@ task = Task.create(
|
|
|
59
79
|
]
|
|
60
80
|
)
|
|
61
81
|
|
|
62
|
-
# update the task status to 'processing'
|
|
63
|
-
task.
|
|
82
|
+
# update the task status to 'processing' and set the value to 0
|
|
83
|
+
task.started()
|
|
64
84
|
try:
|
|
65
85
|
for i in range(100):
|
|
66
86
|
do_something(i)
|
|
67
|
-
if i % 10 == 0:
|
|
87
|
+
if i!= 0 and i % 10 == 0:
|
|
68
88
|
# update the progress of the task
|
|
69
89
|
task.update_progress(i)
|
|
70
90
|
except Exception as e:
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Task Badger Python Client
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
4
|
+
|
|
5
|
+
For full documentation go to https://docs.taskbadger.net/python/.
|
|
3
6
|
|
|
4
7
|
---
|
|
5
8
|
|
|
@@ -42,12 +45,12 @@ task = Task.create(
|
|
|
42
45
|
]
|
|
43
46
|
)
|
|
44
47
|
|
|
45
|
-
# update the task status to 'processing'
|
|
46
|
-
task.
|
|
48
|
+
# update the task status to 'processing' and set the value to 0
|
|
49
|
+
task.started()
|
|
47
50
|
try:
|
|
48
51
|
for i in range(100):
|
|
49
52
|
do_something(i)
|
|
50
|
-
if i % 10 == 0:
|
|
53
|
+
if i!= 0 and i % 10 == 0:
|
|
51
54
|
# update the progress of the task
|
|
52
55
|
task.update_progress(i)
|
|
53
56
|
except Exception as e:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "taskbadger"
|
|
3
|
-
version = "0.1"
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "The official Python SDK for Task Badger"
|
|
5
|
+
license = "Apache-2.0"
|
|
5
6
|
|
|
6
7
|
authors = []
|
|
7
8
|
|
|
@@ -11,6 +12,24 @@ packages = [
|
|
|
11
12
|
]
|
|
12
13
|
include = ["CHANGELOG.md", "taskbadger/internal/py.typed"]
|
|
13
14
|
|
|
15
|
+
homepage = "https://taskbadger.net/"
|
|
16
|
+
repository = "https://github.com/taskbadger/taskbadger-docs"
|
|
17
|
+
documentation = "https://docs.taskbadger.net/"
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Environment :: Web Environment",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python",
|
|
24
|
+
"Programming Language :: Python :: 3.6",
|
|
25
|
+
"Programming Language :: Python :: 3.7",
|
|
26
|
+
"Programming Language :: Python :: 3.8",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
]
|
|
32
|
+
|
|
14
33
|
[tool.poetry.dependencies]
|
|
15
34
|
python = "^3.8"
|
|
16
35
|
httpx = ">=0.15.4,<0.24.0"
|
|
@@ -25,6 +44,7 @@ pytest = "^7.2.1"
|
|
|
25
44
|
isort = "^5.12.0"
|
|
26
45
|
black = "^23.1.0"
|
|
27
46
|
pre-commit = "^3.0.2"
|
|
47
|
+
pytest-httpx = "^0.21.3"
|
|
28
48
|
|
|
29
49
|
[tool.poetry.scripts]
|
|
30
50
|
taskbadger = "taskbadger.cli:app"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
packages = \
|
|
5
|
+
['taskbadger',
|
|
6
|
+
'taskbadger.internal',
|
|
7
|
+
'taskbadger.internal.api',
|
|
8
|
+
'taskbadger.internal.api.action_endpoints',
|
|
9
|
+
'taskbadger.internal.api.task_endpoints',
|
|
10
|
+
'taskbadger.internal.models']
|
|
11
|
+
|
|
12
|
+
package_data = \
|
|
13
|
+
{'': ['*']}
|
|
14
|
+
|
|
15
|
+
install_requires = \
|
|
16
|
+
['attrs>=21.3.0',
|
|
17
|
+
'httpx>=0.15.4,<0.24.0',
|
|
18
|
+
'python-dateutil>=2.8.0,<3.0.0',
|
|
19
|
+
'tomlkit>=0.11.6,<0.12.0',
|
|
20
|
+
'typer[all]>=0.7.0,<0.8.0']
|
|
21
|
+
|
|
22
|
+
entry_points = \
|
|
23
|
+
{'console_scripts': ['taskbadger = taskbadger.cli:app']}
|
|
24
|
+
|
|
25
|
+
setup_kwargs = {
|
|
26
|
+
'name': 'taskbadger',
|
|
27
|
+
'version': '0.2.1',
|
|
28
|
+
'description': 'The official Python SDK for Task Badger',
|
|
29
|
+
'long_description': '# Task Badger Python Client\n\nThis is the official Python SDK for [Task Badger](https://taskbadger.net/).\n\nFor full documentation go to https://docs.taskbadger.net/python/.\n\n---\n\n## Getting Started\n\n### Install\n\n```bash\npip install --upgrade taskbadger\n```\n\n### Configuration\n\n```python\nimport taskbadger\n\ntaskbadger.init(\n organization_slug="my-org",\n project_slug="my-project",\n token="***"\n)\n```\n\n### Usage\n\n```python\nfrom taskbadger import Task, Action, EmailIntegration\n\n# create a new task with custom data and an action definition\ntask = Task.create(\n "task name",\n data={\n "custom": "data"\n },\n actions=[\n Action(\n "*/10%,success,error",\n integration=EmailIntegration(to="me@example.com")\n )\n ]\n)\n\n# update the task status to \'processing\' and set the value to 0\ntask.started()\ntry:\n for i in range(100):\n do_something(i)\n if i!= 0 and i % 10 == 0:\n # update the progress of the task\n task.update_progress(i)\nexcept Exception as e:\n # record task errors\n task.error(data={\n "error": str(e)\n })\n raise\n\n# record task success\ntask.success()\n```\n',
|
|
30
|
+
'author': 'None',
|
|
31
|
+
'author_email': 'None',
|
|
32
|
+
'maintainer': 'None',
|
|
33
|
+
'maintainer_email': 'None',
|
|
34
|
+
'url': 'https://taskbadger.net/',
|
|
35
|
+
'packages': packages,
|
|
36
|
+
'package_data': package_data,
|
|
37
|
+
'install_requires': install_requires,
|
|
38
|
+
'entry_points': entry_points,
|
|
39
|
+
'python_requires': '>=3.8,<4.0',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
setup(**setup_kwargs)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import os
|
|
3
|
-
from typing import List
|
|
4
|
-
|
|
5
3
|
from _contextvars import ContextVar
|
|
4
|
+
from typing import List
|
|
6
5
|
|
|
7
6
|
from taskbadger import Action
|
|
8
7
|
from taskbadger.exceptions import ConfigurationError
|
|
9
8
|
from taskbadger.internal import AuthenticatedClient, errors
|
|
10
9
|
from taskbadger.internal.api.task_endpoints import task_create, task_get, task_partial_update
|
|
11
|
-
from taskbadger.internal.models import PatchedTaskRequest, PatchedTaskRequestData, StatusEnum
|
|
12
|
-
from taskbadger.internal.models import
|
|
13
|
-
from taskbadger.internal.models import TaskData, TaskRequest
|
|
10
|
+
from taskbadger.internal.models import PatchedTaskRequest, PatchedTaskRequestData, StatusEnum, TaskRequestData
|
|
11
|
+
from taskbadger.internal.models import TaskRequest
|
|
14
12
|
from taskbadger.internal.types import UNSET
|
|
15
13
|
|
|
16
14
|
_local = ContextVar("taskbadger_client")
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
def init(organization_slug: str = None, project_slug: str = None, token: str = None):
|
|
18
|
+
"""Initialize Task Badger client
|
|
19
|
+
|
|
20
|
+
Call this function once per thread
|
|
21
|
+
"""
|
|
20
22
|
_init("https://taskbadger.net", organization_slug, project_slug, token)
|
|
21
23
|
|
|
22
24
|
|
|
@@ -39,46 +41,89 @@ def _init(host: str = None, organization_slug: str = None, project_slug: str = N
|
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
|
|
42
|
-
def get_task(task_id: str):
|
|
43
|
-
|
|
44
|
+
def get_task(task_id: str) -> "Task":
|
|
45
|
+
"""Fetch a Task from the API based on its ID.
|
|
46
|
+
|
|
47
|
+
Arguments:
|
|
48
|
+
task_id: The ID of the task to fetch.
|
|
49
|
+
"""
|
|
50
|
+
return Task(task_get.sync(**_make_args(id=task_id)))
|
|
44
51
|
|
|
45
52
|
|
|
46
53
|
def create_task(
|
|
47
54
|
name: str,
|
|
48
55
|
status: StatusEnum = StatusEnum.PENDING,
|
|
49
|
-
value: int =
|
|
50
|
-
value_max: int =
|
|
51
|
-
data: dict =
|
|
56
|
+
value: int = None,
|
|
57
|
+
value_max: int = None,
|
|
58
|
+
data: dict = None,
|
|
52
59
|
actions: List[Action] = None,
|
|
53
|
-
) ->
|
|
60
|
+
) -> "Task":
|
|
61
|
+
"""Create a Task.
|
|
62
|
+
|
|
63
|
+
Arguments:
|
|
64
|
+
name: The name of the task.
|
|
65
|
+
status: The task status.
|
|
66
|
+
value: The current 'value' of the task.
|
|
67
|
+
value_max: The maximum value the task is expected to achieve.
|
|
68
|
+
data: Custom task data.
|
|
69
|
+
actions: Task actions.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Task: The created Task object.
|
|
73
|
+
"""
|
|
74
|
+
value = _none_to_unset(value)
|
|
75
|
+
value_max = _none_to_unset(value_max)
|
|
76
|
+
data = _none_to_unset(data)
|
|
77
|
+
|
|
54
78
|
task = TaskRequest(name=name, status=status, value=value, value_max=value_max)
|
|
55
79
|
if data:
|
|
56
|
-
task.data =
|
|
80
|
+
task.data = TaskRequestData.from_dict(data)
|
|
57
81
|
if actions:
|
|
58
82
|
task.additional_properties = {"actions": [a.to_dict() for a in actions]}
|
|
59
83
|
kwargs = _make_args(json_body=task)
|
|
60
84
|
response = task_create.sync_detailed(**kwargs)
|
|
61
85
|
_check_response(response)
|
|
62
|
-
return response.parsed
|
|
86
|
+
return Task(response.parsed)
|
|
63
87
|
|
|
64
88
|
|
|
65
89
|
def update_task(
|
|
66
90
|
task_id: str,
|
|
67
|
-
name: str =
|
|
68
|
-
status: StatusEnum =
|
|
69
|
-
value: int =
|
|
70
|
-
value_max: int =
|
|
71
|
-
data: dict =
|
|
91
|
+
name: str = None,
|
|
92
|
+
status: StatusEnum = None,
|
|
93
|
+
value: int = None,
|
|
94
|
+
value_max: int = None,
|
|
95
|
+
data: dict = None,
|
|
72
96
|
actions: List[Action] = None,
|
|
73
|
-
) ->
|
|
74
|
-
|
|
97
|
+
) -> "Task":
|
|
98
|
+
"""Update a task.
|
|
99
|
+
Requires only the task ID and fields to update.
|
|
100
|
+
|
|
101
|
+
Arguments:
|
|
102
|
+
task_id: The ID of the task to update.
|
|
103
|
+
name: The name of the task.
|
|
104
|
+
status: The task status.
|
|
105
|
+
value: The current 'value' of the task.
|
|
106
|
+
value_max: The maximum value the task is expected to achieve.
|
|
107
|
+
data: Custom task data.
|
|
108
|
+
actions: Task actions.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Task: The updated Task object.
|
|
112
|
+
"""
|
|
113
|
+
name = _none_to_unset(name)
|
|
114
|
+
status = _none_to_unset(status)
|
|
115
|
+
value = _none_to_unset(value)
|
|
116
|
+
value_max = _none_to_unset(value_max)
|
|
117
|
+
data = _none_to_unset(data)
|
|
118
|
+
|
|
119
|
+
data = UNSET if not data else PatchedTaskRequestData.from_dict(data)
|
|
75
120
|
body = PatchedTaskRequest(name=name, status=status, value=value, value_max=value_max, data=data)
|
|
76
121
|
if actions:
|
|
77
122
|
body.additional_properties = {"actions": [a.to_dict() for a in actions]}
|
|
78
123
|
kwargs = _make_args(id=task_id, json_body=body)
|
|
79
124
|
response = task_partial_update.sync_detailed(**kwargs)
|
|
80
125
|
_check_response(response)
|
|
81
|
-
return response.parsed
|
|
126
|
+
return Task(response.parsed)
|
|
82
127
|
|
|
83
128
|
|
|
84
129
|
def _make_args(**kwargs):
|
|
@@ -107,75 +152,101 @@ class Settings:
|
|
|
107
152
|
project_slug: str
|
|
108
153
|
|
|
109
154
|
|
|
110
|
-
class
|
|
155
|
+
class Task:
|
|
156
|
+
"""The Task class provides a convenient Python API to interact
|
|
157
|
+
with Task Badger tasks.
|
|
158
|
+
"""
|
|
159
|
+
|
|
111
160
|
@classmethod
|
|
112
161
|
def get(cls, task_id: str) -> "Task":
|
|
113
|
-
|
|
162
|
+
"""Get an existing task"""
|
|
163
|
+
return get_task(task_id)
|
|
114
164
|
|
|
115
165
|
@classmethod
|
|
116
166
|
def create(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
167
|
+
cls,
|
|
168
|
+
name: str,
|
|
169
|
+
status: StatusEnum = StatusEnum.PENDING,
|
|
170
|
+
value: int = None,
|
|
171
|
+
value_max: int = None,
|
|
172
|
+
data: dict = None,
|
|
173
|
+
actions: List[Action] = None,
|
|
124
174
|
) -> "Task":
|
|
125
|
-
|
|
126
|
-
|
|
175
|
+
"""Create a new task"""
|
|
176
|
+
return create_task(name, status, value, value_max, data, actions)
|
|
127
177
|
|
|
128
|
-
class Task(TaskAccessorsMixin):
|
|
129
178
|
def __init__(self, task):
|
|
130
179
|
self._task = task
|
|
131
180
|
|
|
132
181
|
def pre_processing(self):
|
|
182
|
+
"""Update the task status to `pre_processing`."""
|
|
133
183
|
self.update_status(StatusEnum.PRE_PROCESSING)
|
|
134
184
|
|
|
135
|
-
def
|
|
185
|
+
def starting(self):
|
|
186
|
+
"""Update the task status to `pre_processing` and set the value to `0`."""
|
|
136
187
|
self.processing(value=0)
|
|
137
188
|
|
|
138
|
-
def processing(self, value: int =
|
|
189
|
+
def processing(self, value: int = None):
|
|
190
|
+
"""Update the task status to `processing` and set the value."""
|
|
139
191
|
self.update(status=StatusEnum.PROCESSING, value=value)
|
|
140
192
|
|
|
141
|
-
def post_processing(self, value: int =
|
|
193
|
+
def post_processing(self, value: int = None):
|
|
194
|
+
"""Update the task status to `post_processing` and set the value."""
|
|
142
195
|
self.update(status=StatusEnum.POST_PROCESSING, value=value)
|
|
143
196
|
|
|
144
|
-
def success(self, value: int =
|
|
197
|
+
def success(self, value: int = None):
|
|
198
|
+
"""Update the task status to `success` and set the value."""
|
|
145
199
|
self.update(status=StatusEnum.SUCCESS, value=value)
|
|
146
200
|
|
|
147
|
-
def error(self, value: int =
|
|
201
|
+
def error(self, value: int = None, data: dict = None):
|
|
202
|
+
"""Update the task status to `error` and set the value and data."""
|
|
148
203
|
self.update(status=StatusEnum.ERROR, value=value, data=data)
|
|
149
204
|
|
|
150
|
-
def
|
|
205
|
+
def canceled(self):
|
|
206
|
+
"""Update the task status to `cancelled`"""
|
|
151
207
|
self.update_status(StatusEnum.CANCELLED)
|
|
152
208
|
|
|
153
209
|
def update_status(self, status: StatusEnum):
|
|
210
|
+
"""Update the task status"""
|
|
154
211
|
self.update(status=status)
|
|
155
212
|
|
|
156
213
|
def increment_progress(self, amount: int):
|
|
157
|
-
|
|
214
|
+
"""Increment the task progress.
|
|
215
|
+
If the task value is not set it will be set to `amount`.
|
|
216
|
+
"""
|
|
217
|
+
value = self._task.value
|
|
218
|
+
value_norm = value if value is not UNSET and value is not None else 0
|
|
219
|
+
new_amount = value_norm + amount
|
|
220
|
+
self.update(value=new_amount)
|
|
158
221
|
|
|
159
222
|
def update_progress(self, value: int):
|
|
223
|
+
"""Update task progress."""
|
|
160
224
|
self.update(value=value)
|
|
161
225
|
|
|
162
226
|
def set_value_max(self, value_max: int):
|
|
227
|
+
"""Set the `value_max`."""
|
|
163
228
|
self.update(value_max=value_max)
|
|
164
229
|
|
|
165
230
|
def update(
|
|
166
231
|
self,
|
|
167
|
-
name: str =
|
|
168
|
-
status: StatusEnum =
|
|
169
|
-
value: int =
|
|
170
|
-
value_max: int =
|
|
171
|
-
data: dict =
|
|
232
|
+
name: str = None,
|
|
233
|
+
status: StatusEnum = None,
|
|
234
|
+
value: int = None,
|
|
235
|
+
value_max: int = None,
|
|
236
|
+
data: dict = None,
|
|
172
237
|
actions: List[Action] = None,
|
|
173
238
|
):
|
|
174
|
-
|
|
239
|
+
"""Generic update method used to update any of the task fields.
|
|
240
|
+
|
|
241
|
+
This can also be used to add actions.
|
|
242
|
+
"""
|
|
243
|
+
task = update_task(
|
|
175
244
|
self._task.id, name=name, status=status, value=value, value_max=value_max, data=data, actions=actions
|
|
176
245
|
)
|
|
246
|
+
self._task = task._task
|
|
177
247
|
|
|
178
248
|
def add_actions(self, actions: List[Action]):
|
|
249
|
+
"""Add actions to the task."""
|
|
179
250
|
self.update(actions=actions)
|
|
180
251
|
|
|
181
252
|
@property
|
|
@@ -184,3 +255,7 @@ class Task(TaskAccessorsMixin):
|
|
|
184
255
|
|
|
185
256
|
def __getattr__(self, item):
|
|
186
257
|
return getattr(self._task, item)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _none_to_unset(value):
|
|
261
|
+
return UNSET if value is None else value
|
taskbadger-0.1/setup.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from setuptools import setup
|
|
3
|
-
|
|
4
|
-
packages = \
|
|
5
|
-
['taskbadger',
|
|
6
|
-
'taskbadger.internal',
|
|
7
|
-
'taskbadger.internal.api',
|
|
8
|
-
'taskbadger.internal.api.action_endpoints',
|
|
9
|
-
'taskbadger.internal.api.task_endpoints',
|
|
10
|
-
'taskbadger.internal.models']
|
|
11
|
-
|
|
12
|
-
package_data = \
|
|
13
|
-
{'': ['*']}
|
|
14
|
-
|
|
15
|
-
install_requires = \
|
|
16
|
-
['attrs>=21.3.0',
|
|
17
|
-
'httpx>=0.15.4,<0.24.0',
|
|
18
|
-
'python-dateutil>=2.8.0,<3.0.0',
|
|
19
|
-
'tomlkit>=0.11.6,<0.12.0',
|
|
20
|
-
'typer[all]>=0.7.0,<0.8.0']
|
|
21
|
-
|
|
22
|
-
entry_points = \
|
|
23
|
-
{'console_scripts': ['taskbadger = taskbadger.cli:app']}
|
|
24
|
-
|
|
25
|
-
setup_kwargs = {
|
|
26
|
-
'name': 'taskbadger',
|
|
27
|
-
'version': '0.1',
|
|
28
|
-
'description': 'The official Python SDK for Task Badger',
|
|
29
|
-
'long_description': '# Task Badger Python Client\nThis is the official Python SDK for [Task Badger](https://taskbadger.net/)\n\n---\n\n## Getting Started\n\n### Install\n\n```bash\npip install --upgrade taskbadger\n```\n\n### Configuration\n\n```python\nimport taskbadger\n\ntaskbadger.init(\n organization_slug="my-org",\n project_slug="my-project",\n token="***"\n)\n```\n\n### Usage\n\n```python\nfrom taskbadger import Task, Action, EmailIntegration\n\n# create a new task with custom data and an action definition\ntask = Task.create(\n "task name",\n data={\n "custom": "data"\n },\n actions=[\n Action(\n "*/10%,success,error",\n integration=EmailIntegration(to="me@example.com")\n )\n ]\n)\n\n# update the task status to \'processing\'\ntask.start()\ntry:\n for i in range(100):\n do_something(i)\n if i % 10 == 0:\n # update the progress of the task\n task.update_progress(i)\nexcept Exception as e:\n # record task errors\n task.error(data={\n "error": str(e)\n })\n raise\n\n# record task success\ntask.success()\n```\n',
|
|
30
|
-
'author': 'None',
|
|
31
|
-
'author_email': 'None',
|
|
32
|
-
'maintainer': 'None',
|
|
33
|
-
'maintainer_email': 'None',
|
|
34
|
-
'url': 'None',
|
|
35
|
-
'packages': packages,
|
|
36
|
-
'package_data': package_data,
|
|
37
|
-
'install_requires': install_requires,
|
|
38
|
-
'entry_points': entry_points,
|
|
39
|
-
'python_requires': '>=3.8,<4.0',
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setup(**setup_kwargs)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Marker file for PEP 561
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_cancel.py
RENAMED
|
File without changes
|
{taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_create.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/action_endpoints/action_update.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/api/task_endpoints/task_partial_update.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-0.1 → taskbadger-0.2.1}/taskbadger/internal/models/patched_action_request_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|