From fe2d6bad1b2fe7ae7dbc67555fa3ebbe9da3be30 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 10 Oct 2017 13:18:00 -0400 Subject: [PATCH] fix logging error for dht rpc methods with no args (ping) --- lbrynet/dht/protocol.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lbrynet/dht/protocol.py b/lbrynet/dht/protocol.py index c4a3782e8..974c45dfe 100644 --- a/lbrynet/dht/protocol.py +++ b/lbrynet/dht/protocol.py @@ -158,7 +158,10 @@ class KademliaProtocol(protocol.DatagramProtocol): msgPrimitive = self._translator.toPrimitive(msg) encodedMsg = self._encoder.encode(msgPrimitive) - log.debug("DHT SEND CALL %s(%s)", method, args[0].encode('hex')) + if args: + log.debug("DHT SEND CALL %s(%s)", method, args[0].encode('hex')) + else: + log.debug("DHT SEND CALL %s", method) df = defer.Deferred() if rawResponse: @@ -372,8 +375,12 @@ class KademliaProtocol(protocol.DatagramProtocol): func = getattr(self._node, method, None) if callable(func) and hasattr(func, 'rpcmethod'): # Call the exposed Node method and return the result to the deferred callback chain - log.debug("DHT RECV CALL %s(%s) %s:%i", method, args[0].encode('hex'), - senderContact.address, senderContact.port) + if args: + log.debug("DHT RECV CALL %s(%s) %s:%i", method, args[0].encode('hex'), + senderContact.address, senderContact.port) + else: + log.debug("DHT RECV CALL %s %s:%i", method, senderContact.address, + senderContact.port) try: kwargs = {'_rpcNodeID': senderContact.id, '_rpcNodeContact': senderContact} result = func(*args, **kwargs)