mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
Move the formatting of RPCRequests to a function so that it's not done every time a rpc request comes
in
This commit is contained in:
parent
0e0cc30128
commit
e79f6ada2f
1 changed files with 27 additions and 18 deletions
|
@ -86,6 +86,32 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
else:
|
else:
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
|
def format_request(call):
|
||||||
|
"""
|
||||||
|
Format the RPCRequest message for debug printing
|
||||||
|
|
||||||
|
:param call: the request
|
||||||
|
:type call: a RPCRequest
|
||||||
|
|
||||||
|
:returns: a formatted string for printing
|
||||||
|
:rtype: str
|
||||||
|
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
s = call[1] + "("
|
||||||
|
if call[2]:
|
||||||
|
s += ", ".join([str(x) for x in call[2]])
|
||||||
|
if call[3]:
|
||||||
|
if call[2]:
|
||||||
|
s += ", "
|
||||||
|
s += ", ".join([key + "=" + str(value) for key, value in call[3].items()])
|
||||||
|
s += ")"
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return "UnicodeEncodeError, call: %s" % call
|
||||||
|
else:
|
||||||
|
return s
|
||||||
|
|
||||||
class DelugeError(Exception):
|
class DelugeError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -151,24 +177,7 @@ class DelugeRPCProtocol(Protocol):
|
||||||
if len(call) != 4:
|
if len(call) != 4:
|
||||||
log.debug("Received invalid rpc request: number of items in request is %s", len(call))
|
log.debug("Received invalid rpc request: number of items in request is %s", len(call))
|
||||||
continue
|
continue
|
||||||
|
#log.debug("RPCRequest: %s", format_request(call))
|
||||||
# Format the RPCRequest message for debug printing
|
|
||||||
try:
|
|
||||||
s = call[1] + "("
|
|
||||||
if call[2]:
|
|
||||||
s += ", ".join([str(x) for x in call[2]])
|
|
||||||
if call[3]:
|
|
||||||
if call[2]:
|
|
||||||
s += ", "
|
|
||||||
s += ", ".join([key + "=" + str(value) for key, value in call[3].items()])
|
|
||||||
s += ")"
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
pass
|
|
||||||
#log.debug("RPCRequest had some non-ascii text..")
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
#log.debug("RPCRequest: %s", s)
|
|
||||||
|
|
||||||
reactor.callLater(0, self.dispatch, *call)
|
reactor.callLater(0, self.dispatch, *call)
|
||||||
|
|
||||||
def sendData(self, data):
|
def sendData(self, data):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue