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 ( 0600e6...77030f )
by P.R.
02:59
created

HaltCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 64
ccs 0
cts 20
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 23 2
A __init__() 0 21 1
A __zmq_init() 0 5 1
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import os
9
10
import zmq
11
from cleo import Command
12
13
import enarksh
14
from enarksh.message.HaltMessage import HaltMessage
15
from enarksh.style.EnarkshStyle import EnarkshStyle
16
17
18
class HaltCommand(Command):
19
    """
20
    Halts a daemon of Enarksh
21
22
    halt
23
24
        {daemon : The Enarksh daemon to halt: controllerd, loggerd, or spanwerd}
25
    """
26
27
    # ------------------------------------------------------------------------------------------------------------------
28
    def __init__(self):
29
        """
30
        Object constructor.
31
        """
32
        Command.__init__(self)
33
34
        self._zmq_context = None
35
        """
36
        The ZMQ context.
37
38
        :type: Context
39
        """
40
41
        self.__end_points = {'controllerd': enarksh.CONTROLLER_PULL_END_POINT,
42
                             'loggerd':     enarksh.LOGGER_PULL_END_POINT,
43
                             'spawnerd':    enarksh.SPAWNER_PULL_END_POINT}
44
        """
45
        The end points of the Enarksh daemons.
46
47
        :type: dict[string,string]
48
        """
49
50
    # ------------------------------------------------------------------------------------------------------------------
51
52
    def __zmq_init(self):
53
        """
54
        Initializes ZMQ.
55
        """
56
        self._zmq_context = zmq.Context()
57
58
    # ------------------------------------------------------------------------------------------------------------------
59
    def handle(self):
60
        """
61
        Executes the halt command.
62
        """
63
        self.output = EnarkshStyle(self.input, self.output)
64
65
        os.chdir(enarksh.HOME)
66
67
        self.__zmq_init()
68
69
        daemon = self.input.get_argument('daemon')
70
71
        if daemon not in self.__end_points:
72
            self.output.error("Unknown daemon '{}'".format(daemon))
73
            return -1
74
75
        # Connect tot the daemon.
76
        zmq_daemon = self._zmq_context.socket(zmq.PUSH)
77
        zmq_daemon.connect(self.__end_points[daemon])
78
79
        # Send the halt message tot the daemon.
80
        message = HaltMessage()
81
        zmq_daemon.send_pyobj(message)
82
83
# ----------------------------------------------------------------------------------------------------------------------
84