backend.when_shutdown.main()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
'''shut down a miner'''
2
from helpers.queuehelper import QueueName
3
from helpers.antminerhelper import shutdown
4
from backend.fcmapp import Component
5
6
SHUTDOWN = Component('shutdown')
7
8
def when_shutdown(channel, method, properties, body):
9
    msg = SHUTDOWN.app.messagedecodeminer(body)
10
    miner = msg.miner
11
    minercommand = msg.command
12
    #sanity check
13
    if minercommand.command == 'shutdown':
14
        #here you implement specific logic to shutdown your miner
15
        shutdown(miner, SHUTDOWN.app.sshlogin())
16
17
def main():
18
    SHUTDOWN.listeningqueue = SHUTDOWN.app.subscribe(QueueName.Q_SHUTDOWN, when_shutdown, no_acknowledge=True)
19
    SHUTDOWN.app.listen(SHUTDOWN.listeningqueue)
20
21
if __name__ == "__main__":
22
    main()
23