GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( aee9c5...6ca25e )
by P.R.
03:23
created

SimpleNode.start()   A

Complexity

Conditions 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 5
cp 0
crap 2
rs 9.4285
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import enarksh
9
from enarksh.controller.StateChange import StateChange
10
from enarksh.controller.node.Node import Node
11
12
13
class SimpleNode(Node):
14
    """
15
    Class for objects in the controller of type 'SimpleJob'.
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def is_simple_node(self):
20
        """
21
        Returns True.
22
23
        :rtype: bool
24
        """
25
        return True
26
27
    # ------------------------------------------------------------------------------------------------------------------
28
    def is_complex_node(self):
29
        """
30
        Returns False.
31
32
        :rtype: bool
33
        """
34
        return False
35
36
    # ------------------------------------------------------------------------------------------------------------------
37
    @StateChange.wrapper
38
    def start(self):
39
        """
40
        Does the housekeeping for starting this node. Returns True if an actual job must be started by the spawner.
41
        Returns False otherwise.
42
43
        :rtype: bool
44
        """
45
        # Acquire the required resources of this node.
46
        self.acquire_resources()
47
48
        # Set the status of this node to running.
49
        self._set_rst_id(enarksh.ENK_RST_ID_RUNNING)
50
51
        return True
52
53
    # ------------------------------------------------------------------------------------------------------------------
54
    @StateChange.wrapper
55
    def stop(self, exit_status):
56
        """
57
        Does the housekeeping when the node has stopped.
58
59
        :param int exit_status: The exits status of the job.
60
        """
61
        # Release all by this node consumed resources.
62
        self.release_resources()
63
64
        # Save the exit status of the job.
65
        self._exit_status = exit_status
66
67
        # Update the run status of this node based on the exit status of the job.
68
        if exit_status == 0:
69
            self._set_rst_id(enarksh.ENK_RST_ID_COMPLETED)
70
        else:
71
            self._set_rst_id(enarksh.ENK_RST_ID_ERROR)
72
73
    # ------------------------------------------------------------------------------------------------------------------
74
    @StateChange.wrapper
75
    def restart(self):
76
        """
77
        Restart this node and its successors.
78
        """
79
        if self.rst_id in (enarksh.ENK_RST_ID_ERROR, enarksh.ENK_RST_ID_COMPLETED):
80
            self._renew()
81
            self._recompute_run_status()
82
83
    # ------------------------------------------------------------------------------------------------------------------
84
    @StateChange.wrapper
85
    def restart_failed(self):
86
        """
87
        Restart this node.
88
        """
89
        if self.rst_id == enarksh.ENK_RST_ID_ERROR:
90
            self._renew()
91
            self._recompute_run_status()
92
        else:
93
            raise Exception("Not possible to restart node with rst_id '{0!s}'.".format(self.rst_id))
94
95
# ----------------------------------------------------------------------------------------------------------------------
96