Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from __future__ import print_function
- from twisted.internet.protocol import Protocol, Factory
- from twisted.internet import reactor
- from pprint import pprint
- import json
- class Echo(Protocol):
- def dataReceived(self, data):
- print("data received")
- miner = json.loads(data)
- mac = miner['ctrl_board']
- hashboard = miner['hashboard']
- board1 = hashboard[0]['ID']
- board2 = hashboard[1]['ID']
- board3 = hashboard[2]['ID']
- id= miner['id']
- ip = self.transport.getPeer()
- print("IP " + str(ip))
- print("mac " + mac)
- print("board 1 " + board1)
- print("board 2 " + board2)
- print("board 3 " + board3)
- print("id " + id)
- boards = {
- "board1": board1,
- "board2": board2,
- "board3": board3,
- "id": id
- }
- self.transport.write("false")
- pprint(boards)
- def main():
- f = Factory()
- f.protocol = Echo
- reactor.listenTCP(7000, f)
- reactor.run()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement