|
1
|
|
|
from __future__ import ( |
|
|
|
|
|
|
2
|
|
|
absolute_import, |
|
3
|
|
|
division, |
|
4
|
|
|
print_function |
|
5
|
|
|
) |
|
6
|
|
|
|
|
7
|
|
|
import logging |
|
8
|
|
|
|
|
9
|
|
|
import boto.swf.layer2 as swf |
|
|
|
|
|
|
10
|
|
|
from boto.swf.exceptions import ( |
|
|
|
|
|
|
11
|
|
|
SWFTypeAlreadyExistsError, |
|
12
|
|
|
SWFDomainAlreadyExistsError, |
|
13
|
|
|
) |
|
14
|
|
|
|
|
15
|
|
|
_LOGGER = logging.getLogger(__name__) |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
def register(domain='test', workflows=(), activities=()): |
|
|
|
|
|
|
19
|
|
|
registerables = [] |
|
20
|
|
|
registerables.append(swf.Domain(name=domain)) |
|
21
|
|
|
|
|
22
|
|
|
for (workflow_name, workflow_version, |
|
23
|
|
|
default_execution_start_to_close_timeout, |
|
|
|
|
|
|
24
|
|
|
default_task_start_to_close_timeout) in workflows: |
|
|
|
|
|
|
25
|
|
|
registerables.append( |
|
26
|
|
|
swf.WorkflowType(domain=domain, |
|
27
|
|
|
name=workflow_name, |
|
28
|
|
|
default_execution_start_to_close_timeout=default_execution_start_to_close_timeout, |
|
|
|
|
|
|
29
|
|
|
default_task_start_to_close_timeout=default_task_start_to_close_timeout, |
|
|
|
|
|
|
30
|
|
|
version=workflow_version, |
|
31
|
|
|
task_list='default') |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
|
|
for (activity_name, activity_version) in activities: |
|
35
|
|
|
registerables.append( |
|
36
|
|
|
swf.ActivityType(domain=domain, |
|
37
|
|
|
name=activity_name, |
|
38
|
|
|
version=activity_version, |
|
39
|
|
|
task_list='default') |
|
40
|
|
|
) |
|
41
|
|
|
|
|
42
|
|
|
for swf_entity in registerables: |
|
43
|
|
|
try: |
|
44
|
|
|
swf_entity.register() |
|
45
|
|
|
_LOGGER.info('%r registered successfully', swf_entity.name) |
|
46
|
|
|
except (SWFDomainAlreadyExistsError, SWFTypeAlreadyExistsError): |
|
47
|
|
|
_LOGGER.warning('%s %r already exists', |
|
48
|
|
|
swf_entity.__class__.__name__, |
|
49
|
|
|
swf_entity.name) |
|
50
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.