Test Setup Failed
Pull Request — master (#4154)
by W
03:37
created

WorkflowExecutionNotFoundException.__init__()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
from __future__ import absolute_import
17
18
from st2common import exceptions as st2_exc
19
from st2common.exceptions import db as db_exc
20
from st2common import log as logging
21
22
23
LOG = logging.getLogger(__name__)
24
25
26
def retry_on_exceptions(exc):
27
    LOG.warning('Determining if exception %s should be retried.', type(exc))
28
29
    retrying = isinstance(exc, db_exc.StackStormDBObjectWriteConflictError)
30
31
    if retrying:
32
        LOG.warning('Retrying operation due to database write conflict.')
33
34
    return retrying
35
36
37
class WorkflowDefinitionException(st2_exc.StackStormBaseException):
38
    pass
39
40
41
class WorkflowExecutionNotFoundException(st2_exc.StackStormBaseException):
42
43
    def __init__(self, ac_ex_id):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class StackStormBaseException is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
44
        Exception.__init__(
0 ignored issues
show
Bug introduced by
The __init__ of the immediate ancestor is not called instead this calls
the method of another ancestor Exception.

It is usually advisable to call the __init__ method of the immediate ancestor instead of another ancestor in the inheritance chain:

class NonDirectParent:
    def __init__(self):
        pass

class DirectParent(NonDirectParent):
    def __init__(self):
        NonDirectParent.__init__(self)

class YourClass(DirectParent):
    def __init__(self):
        NonDirectParent.__init__(self) # Bad
        DirectParent.__init__(self)    # Good
Loading history...
45
            self,
46
            'Unable to identify any workflow execution that is '
47
            'associated to action execution "%s".' % ac_ex_id
48
        )
49
50
51
class AmbiguousWorkflowExecutionException(st2_exc.StackStormBaseException):
52
53
    def __init__(self, ac_ex_id):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class StackStormBaseException is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
54
        Exception.__init__(
0 ignored issues
show
Bug introduced by
The __init__ of the immediate ancestor is not called instead this calls
the method of another ancestor Exception.

It is usually advisable to call the __init__ method of the immediate ancestor instead of another ancestor in the inheritance chain:

class NonDirectParent:
    def __init__(self):
        pass

class DirectParent(NonDirectParent):
    def __init__(self):
        NonDirectParent.__init__(self)

class YourClass(DirectParent):
    def __init__(self):
        NonDirectParent.__init__(self) # Bad
        DirectParent.__init__(self)    # Good
Loading history...
55
            self,
56
            'More than one workflow execution is associated '
57
            'to action execution "%s".' % ac_ex_id
58
        )
59
60
61
class WorkflowExecutionIsCompletedException(st2_exc.StackStormBaseException):
62
63
    def __init__(self, wf_ex_id):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class StackStormBaseException is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
64
        Exception.__init__(self, 'Workflow execution "%s" is already completed.' % wf_ex_id)
0 ignored issues
show
Bug introduced by
The __init__ of the immediate ancestor is not called instead this calls
the method of another ancestor Exception.

It is usually advisable to call the __init__ method of the immediate ancestor instead of another ancestor in the inheritance chain:

class NonDirectParent:
    def __init__(self):
        pass

class DirectParent(NonDirectParent):
    def __init__(self):
        NonDirectParent.__init__(self)

class YourClass(DirectParent):
    def __init__(self):
        NonDirectParent.__init__(self) # Bad
        DirectParent.__init__(self)    # Good
Loading history...
65
66
67
class WorkflowExecutionIsRunningException(st2_exc.StackStormBaseException):
68
69
    def __init__(self, wf_ex_id):
0 ignored issues
show
Bug introduced by
The __init__ method of the super-class StackStormBaseException is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
70
        Exception.__init__(self, 'Workflow execution "%s" is already active.' % wf_ex_id)
0 ignored issues
show
Bug introduced by
The __init__ of the immediate ancestor is not called instead this calls
the method of another ancestor Exception.

It is usually advisable to call the __init__ method of the immediate ancestor instead of another ancestor in the inheritance chain:

class NonDirectParent:
    def __init__(self):
        pass

class DirectParent(NonDirectParent):
    def __init__(self):
        NonDirectParent.__init__(self)

class YourClass(DirectParent):
    def __init__(self):
        NonDirectParent.__init__(self) # Bad
        DirectParent.__init__(self)    # Good
Loading history...
71