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.

NagiosMessageEventHandler.handle()   B
last analyzed

Complexity

Conditions 3

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 37
ccs 0
cts 14
cp 0
crap 12
rs 8.8571
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import logging
9
10
from enarksh.C import C
11
from enarksh.DataLayer import DataLayer
12
from enarksh.controller.event_handler.NodeActionMessageBaseEventHandler import NodeActionMessageBaseEventHandler
13
14
15
class NagiosMessageEventHandler(NodeActionMessageBaseEventHandler):
16
    """
17
    An event handler for a NagiosMessage received events.
18
    """
19
20
    # ------------------------------------------------------------------------------------------------------------------
21
    @staticmethod
22
    def handle(_event, _message, controller):
23
        """
24
        Handles a NagiosMessage received event.
25
26
        :param * _event: Not used.
27
        :param * _message: Not used.
28
        :param enarksh.controller.Controller.Controller controller: The controller.
29
        """
30
        del _event, _message
31
32
        log = logging.getLogger('enarksh')
33
34
        rst_count = {C.ENK_RST_ID_COMPLETED: 0,
35
                     C.ENK_RST_ID_ERROR:     0,
36
                     C.ENK_RST_ID_QUEUED:    0,
37
                     C.ENK_RST_ID_RUNNING:   0,
38
                     C.ENK_RST_ID_WAITING:   0}
39
40
        response = {'ret':       0,
41
                    'rst_count': rst_count,
42
                    'sch_count': len(controller.schedules)}
43
44
        try:
45
            for schedule in controller.schedules.values():
46
                schedule.nagios_performance_data(rst_count)
47
48
        except Exception as exception:
49
            log.exception('Error')
50
51
            response['ret'] = -1
52
            response['message'] = str(exception)
53
54
            DataLayer.rollback()
55
56
        # Send response message to the CLI client.
57
        controller.message_controller.send_message('lockstep', response)
58
59
# ----------------------------------------------------------------------------------------------------------------------
60