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

NodeActionClient.main()   B

Complexity

Conditions 3

Size

Total Lines 26

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 26
ccs 0
cts 10
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 os
0 ignored issues
show
Unused Code introduced by
The import os seems to be unused.
Loading history...
9
import sys
0 ignored issues
show
Unused Code introduced by
The import sys seems to be unused.
Loading history...
10
import traceback
0 ignored issues
show
Unused Code introduced by
The import traceback seems to be unused.
Loading history...
11
12
import zmq
13
14
import enarksh
15
from enarksh.controller.message.NodeActionMessage import NodeActionMessage
16
from enarksh.controller.message.ScheduleDefinitionMessage import ScheduleDefinitionMessage
0 ignored issues
show
Unused Code introduced by
Unused ScheduleDefinitionMessage imported from enarksh.controller.message.ScheduleDefinitionMessage
Loading history...
17
18
19
class NodeActionClient:
20
    """
21
    A client for requesting the controller for a node action.
22
    """
23
24
    # ------------------------------------------------------------------------------------------------------------------
25
    def __init__(self):
26
        self._zmq_context = None
27
        """
28
        The ZMQ context.
29
30
        :type: Context
31
        """
32
33
        self._zmq_controller = None
34
        """
35
        The socket for communicating with the controller.
36
37
        :type: zmq.sugar.socket.Socket
38
        """
39
40
    # ------------------------------------------------------------------------------------------------------------------
41
    def main(self, uri, act_id):
42
        """
43
        The main function of node_action.
44
45
        :param str uri: The URI of the (trigger) node that must be triggered.
46
        :param int act_id: The ID of the requested action.
47
        """
48
        # Initialize ZMQ.
49
        self._zmq_init()
50
51
        # Compose the message for the controller.
52
        message = NodeActionMessage(uri, act_id, False, False)
53
54
        # Send the message to the controller.
55
        self._zmq_controller.send_pyobj(message)
56
57
        # Await the response from the controller.
58
        response = self._zmq_controller.recv_pyobj()
59
60
        print(response['message'], end='')
61
        if response['message'] and response['message'][-1:] != '\n':
62
            print()
63
64
        print(response)
65
66
        return response['ret']
67
68
    # ------------------------------------------------------------------------------------------------------------------
69
    def _zmq_init(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
70
        self._zmq_context = zmq.Context()
71
72
        # Create socket for communicating with the controller.
73
        self._zmq_controller = self._zmq_context.socket(zmq.REQ)
1 ignored issue
show
Bug introduced by
The Module zmq does not seem to have a member named REQ.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
74
        self._zmq_controller.connect(enarksh.CONTROLLER_LOCKSTEP_END_POINT)
75
76
77
# ----------------------------------------------------------------------------------------------------------------------
78