backend.when_shutdown   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A when_shutdown() 0 8 2
A main() 0 3 1
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