From 0b2c09d20b389af4ab1fef4ad6061fe64fafd15f Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 4 Oct 2013 16:00:20 +0200 Subject: [PATCH] interface.debug flag --- lib/interface.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/interface.py b/lib/interface.py index 804e63cb4..3421b50fb 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -103,6 +103,8 @@ class Interface(threading.Thread): self.is_connected = False self.poll_interval = 1 + self.debug = False # dump network messages. can be changed at runtime using the console + #json self.message_id = 0 self.unanswered_requests = {} @@ -131,7 +133,8 @@ class Interface(threading.Thread): def queue_json_response(self, c): # uncomment to debug - # print_error( "<--",c ) + if self.debug: + print_error( "<--",c ) msg_id = c.get('id') error = c.get('error') @@ -433,8 +436,8 @@ class Interface(threading.Thread): request = json.dumps( { 'id':self.message_id, 'method':method, 'params':params } ) self.unanswered_requests[self.message_id] = method, params, callback ids.append(self.message_id) - # uncomment to debug - # print "-->", request + if self.debug: + print "-->", request self.message_id += 1 out += request + '\n' while out: