register()   B
last analyzed

Complexity

Conditions 5

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 5
c 3
b 0
f 0
dl 0
loc 32
rs 8.0894
1
from __future__ import (
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
    absolute_import,
3
    division,
4
    print_function
5
)
6
7
import logging
8
9
import boto.swf.layer2 as swf
0 ignored issues
show
Configuration introduced by
The import boto.swf.layer2 could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
10
from boto.swf.exceptions import (
0 ignored issues
show
Configuration introduced by
The import boto.swf.exceptions could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
11
    SWFTypeAlreadyExistsError,
12
    SWFDomainAlreadyExistsError,
13
)
14
15
_LOGGER = logging.getLogger(__name__)
16
17
18
def register(domain='test', workflows=(), activities=()):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
19
    registerables = []
20
    registerables.append(swf.Domain(name=domain))
21
22
    for (workflow_name, workflow_version,
23
         default_execution_start_to_close_timeout,
0 ignored issues
show
Coding Style Naming introduced by
The name default_execution_start_to_close_timeout does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
24
         default_task_start_to_close_timeout) in workflows:
0 ignored issues
show
Coding Style Naming introduced by
The name default_task_start_to_close_timeout does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
29
                             default_task_start_to_close_timeout=default_task_start_to_close_timeout,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
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