logging and whitespace

This commit is contained in:
Jack Robison 2017-10-10 13:29:29 -04:00
parent 5937ead17c
commit c9515f8fb6
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
3 changed files with 5 additions and 3 deletions

View file

@ -182,8 +182,9 @@ class Node(object):
def printContacts(self, *args): def printContacts(self, *args):
print '\n\nNODE CONTACTS\n===============' print '\n\nNODE CONTACTS\n==============='
for i in range(len(self._routingTable._buckets)): for i in range(len(self._routingTable._buckets)):
print "bucket %i" % i
for contact in self._routingTable._buckets[i]._contacts: for contact in self._routingTable._buckets[i]._contacts:
print contact print " %s:%i" % (contact.address, contact.port)
print '==================================' print '=================================='
def getApproximateTotalDHTNodes(self): def getApproximateTotalDHTNodes(self):
@ -510,6 +511,7 @@ class Node(object):
node is returning all of the contacts that it knows of. node is returning all of the contacts that it knows of.
@rtype: list @rtype: list
""" """
# Get the sender's ID (if any) # Get the sender's ID (if any)
if '_rpcNodeID' in kwargs: if '_rpcNodeID' in kwargs:
rpc_sender_id = kwargs['_rpcNodeID'] rpc_sender_id = kwargs['_rpcNodeID']

View file

@ -399,7 +399,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
def _msgTimeout(self, messageID): def _msgTimeout(self, messageID):
""" Called when an RPC request message times out """ """ Called when an RPC request message times out """
# Find the message that timed out # Find the message that timed out
if not self._sentMessages.has_key(messageID): if messageID not in self._sentMessages:
# This should never be reached # This should never be reached
log.error("deferred timed out, but is not present in sent messages list!") log.error("deferred timed out, but is not present in sent messages list!")
return return

View file

@ -84,7 +84,7 @@ class TreeRoutingTable(object):
@type failure: twisted.python.failure.Failure @type failure: twisted.python.failure.Failure
""" """
failure.trap(TimeoutError) failure.trap(TimeoutError)
print '==replacing contact==' log.warning('==replacing contact==')
# Remove the old contact... # Remove the old contact...
deadContactID = failure.getErrorMessage() deadContactID = failure.getErrorMessage()
try: try: