kuflow-temporal-activity-robotframework 3.2.1__py3-none-any.whl
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.
- kuflow_temporal_activity_robotframework/__init__.py +30 -0
- kuflow_temporal_activity_robotframework/robot_framework_activities.py +148 -0
- kuflow_temporal_activity_robotframework-3.2.1.dist-info/METADATA +42 -0
- kuflow_temporal_activity_robotframework-3.2.1.dist-info/RECORD +5 -0
- kuflow_temporal_activity_robotframework-3.2.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#
|
|
2
|
+
# MIT License
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2022 KuFlow
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
# copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
# SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
from .robot_framework_activities import RobotFrameworkActivities
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = ["RobotFrameworkActivities"]
|
|
29
|
+
|
|
30
|
+
__version__ = "3.2.1"
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#
|
|
2
|
+
# MIT License
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2022 KuFlow
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
# copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
# SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
import os
|
|
26
|
+
from dataclasses import dataclass, field
|
|
27
|
+
from typing import Optional
|
|
28
|
+
|
|
29
|
+
import robot
|
|
30
|
+
from temporalio import activity
|
|
31
|
+
from temporalio.exceptions import ApplicationError
|
|
32
|
+
|
|
33
|
+
from kuflow_temporal_common import KuFlowFailureType, auto_heartbeater
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _default_variables() -> list[str]:
|
|
37
|
+
return []
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _default_additional_options() -> dict:
|
|
41
|
+
return {}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class ExecuteRobotRequest:
|
|
46
|
+
"""Data class for execute robot activity.
|
|
47
|
+
|
|
48
|
+
Attributes:
|
|
49
|
+
tests: Paths to test case files/directories to be executed similarly
|
|
50
|
+
as when running the ``robot`` command on the command line.
|
|
51
|
+
If the KUFLOW_ROBOT_PATH environment variable defined in the
|
|
52
|
+
activity worker exists, its content is added as a prefix to the
|
|
53
|
+
value of this field.
|
|
54
|
+
variables: Options to configure and control execution.
|
|
55
|
+
Take precedence over possible "variable" key present in :param options.
|
|
56
|
+
Take precedence over default_variables in :class:`RobotFrameworkActivities`.
|
|
57
|
+
Values are merged.
|
|
58
|
+
Please see :func:`robot.run.run` docstring to more info
|
|
59
|
+
options: Options to configure and control execution.
|
|
60
|
+
Take precedence over default_options in :class:`RobotFrameworkActivities`
|
|
61
|
+
Values are merged.
|
|
62
|
+
Please see :func:`robot.run.run` docstring to more info
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
tests: str
|
|
66
|
+
|
|
67
|
+
variables: list[str] = field(default_factory=_default_variables)
|
|
68
|
+
|
|
69
|
+
options: dict = field(default_factory=_default_additional_options)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class RobotFrameworkActivities:
|
|
73
|
+
"""
|
|
74
|
+
Set of Temporal.io activities to manage Robot Framework activities
|
|
75
|
+
|
|
76
|
+
Arguments:
|
|
77
|
+
default_variables (Optional[List[str]]): Variables to pass to the robot.
|
|
78
|
+
Format: ["<key>:<value>"]. Example: ["key1:value1", "key2:000"]
|
|
79
|
+
It is equivalent to setting the variables on the command line of 'robot'.
|
|
80
|
+
Important. Take precedence over "variable" key in :arg default_options. Values are merged.
|
|
81
|
+
We recommend avoiding the "variable" key in default_options and using the
|
|
82
|
+
default_variables field for it.
|
|
83
|
+
These variables can be overridden in activity invocations.
|
|
84
|
+
default_options (Optional[dict]): Options to configure and control execution.
|
|
85
|
+
These options can be overridden in activity invocations.
|
|
86
|
+
Please see :func:`robot.run.run` docstring to more info.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def __init__(
|
|
90
|
+
self,
|
|
91
|
+
default_variables: Optional[list[str]] = None,
|
|
92
|
+
default_options: Optional[dict] = None,
|
|
93
|
+
) -> None:
|
|
94
|
+
if default_options is None:
|
|
95
|
+
default_options = {}
|
|
96
|
+
if default_variables is None:
|
|
97
|
+
default_variables = []
|
|
98
|
+
|
|
99
|
+
merge_variables = self._merge_variables(default_options.get("variable"), default_variables)
|
|
100
|
+
options = {**default_options, **{"variable": merge_variables}}
|
|
101
|
+
|
|
102
|
+
self._default_options = options
|
|
103
|
+
self.activities = [self.execute_robot]
|
|
104
|
+
|
|
105
|
+
@activity.defn(name="KuFlow_RobotFramework_ExecuteRobot")
|
|
106
|
+
@auto_heartbeater
|
|
107
|
+
async def execute_robot(self, request: ExecuteRobotRequest):
|
|
108
|
+
# Prepare
|
|
109
|
+
merge_variables_in_request = self._merge_variables(request.options.get("variable"), request.variables)
|
|
110
|
+
merge_variables_in_default = self._merge_variables(
|
|
111
|
+
self._default_options.get("variable"), merge_variables_in_request
|
|
112
|
+
)
|
|
113
|
+
options = {**self._default_options, **{"variable": merge_variables_in_default}}
|
|
114
|
+
|
|
115
|
+
tests = self._prepend_robot_path_variable(request.tests)
|
|
116
|
+
|
|
117
|
+
# Run
|
|
118
|
+
robot_code = robot.run(tests, **options)
|
|
119
|
+
|
|
120
|
+
if robot_code != 0:
|
|
121
|
+
raise ApplicationError(
|
|
122
|
+
f"Robot finished with undesired status value of ${robot_code}",
|
|
123
|
+
type=KuFlowFailureType.ACTIVITIES_FAILURE,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def _merge_variables(self, variables: list = None, variables_overwrite: list = None):
|
|
127
|
+
# Merge two lists of variables, giving priority to those in variables_overwrite
|
|
128
|
+
if variables_overwrite is None:
|
|
129
|
+
variables_overwrite = []
|
|
130
|
+
if variables is None:
|
|
131
|
+
variables = []
|
|
132
|
+
|
|
133
|
+
merge_variables = variables_overwrite + variables
|
|
134
|
+
# Remove duplicates
|
|
135
|
+
unique_variables = list({s.split(":", 1)[0]: s for s in merge_variables}.values())
|
|
136
|
+
|
|
137
|
+
return unique_variables
|
|
138
|
+
|
|
139
|
+
def _prepend_robot_path_variable(self, relative_path):
|
|
140
|
+
# Check if the "KUFLOW_ROBOT_PATH" environment variable is defined
|
|
141
|
+
robot_path = os.getenv("KUFLOW_ROBOT_PATH")
|
|
142
|
+
|
|
143
|
+
# If is defined, prepend it to the relative path
|
|
144
|
+
if robot_path is not None:
|
|
145
|
+
absolute_path = os.path.join(robot_path, relative_path)
|
|
146
|
+
return absolute_path
|
|
147
|
+
else:
|
|
148
|
+
return relative_path
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: kuflow-temporal-activity-robotframework
|
|
3
|
+
Version: 3.2.1
|
|
4
|
+
Summary: KuFlow SDK :: Temporal.io activities to execute Robot Frameworks tasks
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: KuFlow S.L.
|
|
7
|
+
Author-email: kuflow@kuflow.com
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: kuflow-temporal-common (>=3.2.1,<4.0.0)
|
|
17
|
+
Requires-Dist: robotframework (>5.0.0)
|
|
18
|
+
Project-URL: Documentation, https://docs.kuflow.com/
|
|
19
|
+
Project-URL: Homepage, https://kuflow.com/
|
|
20
|
+
Project-URL: Repository, https://github.com/kuflow/kuflow-sdk-python
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
[](https://github.com/kuflow/kuflow-sdk-python/blob/master/LICENSE)
|
|
24
|
+
[](https://pypi.org/project/kuflow-temporal-activity-robotframework)
|
|
25
|
+
[](https://pypi.org/project/kuflow-temporal-activity-robotframework)
|
|
26
|
+
|
|
27
|
+
# KuFlow Temporal Activities Robot Framework
|
|
28
|
+
|
|
29
|
+
Temporal.io activities to execute Robot Framework tasks, aka RPA
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
More detailed docs are available in the [documentation pages](https://docs.kuflow.com/developers/).
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
We are happy to receive your help and comments, together we will dance a wonderful KuFlow. Please review our [contribution guide](CONTRIBUTING.md).
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
[MIT License](https://github.com/kuflow/kuflow-sdk-python/blob/master/LICENSE)
|
|
42
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
kuflow_temporal_activity_robotframework/__init__.py,sha256=dqPVjhjWk4rlYGXXJHS934cwlUvZmA2o42slgyzt-Mc,1235
|
|
2
|
+
kuflow_temporal_activity_robotframework/robot_framework_activities.py,sha256=FjAFbTW7VejJVO4RhGwhFk4ig0fNjz0S5qAURQ1FEYo,5924
|
|
3
|
+
kuflow_temporal_activity_robotframework-3.2.1.dist-info/METADATA,sha256=7s8BoMx1NHv9Le7fP1HYQ30-zAvcc_n6gtrduS-ZZdc,1831
|
|
4
|
+
kuflow_temporal_activity_robotframework-3.2.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
5
|
+
kuflow_temporal_activity_robotframework-3.2.1.dist-info/RECORD,,
|