-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.py
26 lines (22 loc) · 841 Bytes
/
repl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logging
from protocol import Protocol
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
consoleHandler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
consoleHandler.setFormatter(formatter)
consoleHandler.setLevel(logging.DEBUG)
logger.addHandler(consoleHandler)
class REPLProtocol(Protocol):
def __init__(self, repoID, discoveryUDPPort, erapTCPPort, peer):
super(REPLProtocol, self).__init__(repoID, discoveryUDPPort, erapTCPPort)
self.peer = peer
def run(self):
logger.info("Starting REPL")
while (True):
text = input()
if text == "peers":
print(self.peer.peers)
print()
if text == "data":
print(self.peer.repository.data)