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.
Passed
Push — master ( f1939b...e2cb7a )
by P.R.
04:00
created

NagiosMessageEventHandler.handle()   B

Complexity

Conditions 3

Size

Total Lines 36

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 36
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 sys
9
import traceback
10
11
import enarksh
12
from enarksh.DataLayer import DataLayer
13
from enarksh.controller.event_handler.NodeActionMessageBaseEventHandler import NodeActionMessageBaseEventHandler
14
15
16
class NagiosMessageEventHandler(NodeActionMessageBaseEventHandler):
17
    """
18
    An event handler for a NagiosMessage received events.
19
    """
20
21
    # ------------------------------------------------------------------------------------------------------------------
22
    @staticmethod
23
    def handle(_event, _message, controller):
24
        """
25
        Handles a NagiosMessage received event.
26
27
        :param * _event: Not used.
28
        :param * _message: Not used.
29
        :param enarksh.controller.Controller.Controller controller: The controller.
30
        """
31
        del _event, _message
32
33
        rst_count = {enarksh.ENK_RST_ID_COMPLETED: 0,
34
                     enarksh.ENK_RST_ID_ERROR:     0,
35
                     enarksh.ENK_RST_ID_QUEUED:    0,
36
                     enarksh.ENK_RST_ID_RUNNING:   0,
37
                     enarksh.ENK_RST_ID_WAITING:   0}
38
39
        response = {'ret':       0,
40
                    'rst_count': rst_count,
41
                    'sch_count': len(controller.schedules)}
42
43
        try:
44
            for schedule in controller.schedules:
45
                schedule.nagios_performance_data(rst_count)
46
47
        except Exception as exception:
1 ignored issue
show
Best Practice introduced by
Catching very general exceptions such as Exception is usually not recommended.

Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.

So, unless you specifically plan to handle any error, consider adding a more specific exception.

Loading history...
48
            print(exception, file=sys.stderr)
49
            traceback.print_exc(file=sys.stderr)
50
51
            response['ret'] = -1
52
            response['message'] = 'Internal error'
53
54
            DataLayer.rollback()
55
56
        # Send response message to the CLI client.
57
        controller.message_controller.send_message('lockstep', response)
58
59
# ----------------------------------------------------------------------------------------------------------------------
60