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 ( fac2c4...4a4d5a )
by P.R.
03:39
created

NodeActionMessageBaseEventHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 49
ccs 0
cts 16
cp 0
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B base_handle() 0 43 6
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import enarksh
9
from enarksh.controller.Schedule import Schedule
10
11
12
class NodeActionMessageBaseEventHandler:
13
    """
14
    A base event handler for a NodeActionMessage or received events.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18
    @staticmethod
19
    def base_handle(controller, response, sch_id, rnd_id, act_id, usr_login, mail_on_completion, mail_on_error):
20
        """
21
        Handles a NodeActionMessage received event.
22
23
        :param enarksh.controller.Controller.Controller controller: The controller.
24
        :param dict response: The response to the client.
25
        :param int sch_id: The ID of the schedule.
26
        :param int rnd_id: The ID of the node.
27
        :param int act_id: The ID of the requested action.
28
        :param str usr_login: The name of the user who has requested the node action.
29
        :param bool mail_on_completion: If True the user wants to receive a mail when the schedule has completed.
30
        :param bool mail_on_error: If True the user wants to receive a mail when an error occurs.
31
        """
32
        schedule = controller.get_schedule_by_sch_id(sch_id)
33
        if schedule:
34
            actions = schedule.request_possible_node_actions(rnd_id)
35
        else:
36
            actions = Schedule.get_response_template()
37
38
        if act_id not in actions['actions'] or not actions['actions'][act_id]['act_enabled']:
39
            response['ret'] = -1
40
            response['message'] = 'Not a valid action'
41
        else:
42
            schedule = controller.get_schedule_by_sch_id(sch_id)
43
            reload = schedule.request_node_action(rnd_id,
44
                                                  act_id,
45
                                                  usr_login,
46
                                                  mail_on_completion,
47
                                                  mail_on_error)
48
            if reload:
49
                # Schedule must be reloaded.
50
                schedule = controller.reload_schedule(schedule.sch_id)
51
                # A reload is only required when the schedule is been triggered. However, this trigger is lost by
52
                # reloading the schedule. So, resend the trigger.
53
                schedule.request_node_action(schedule.get_activate_node().rnd_id,
54
                                             act_id,
55
                                             usr_login,
56
                                             mail_on_completion,
57
                                             mail_on_error)
58
59
            if act_id == enarksh.ENK_ACT_ID_TRIGGER:
60
                response['new_run'] = 1
61
62
# ----------------------------------------------------------------------------------------------------------------------
63