From 8eab23789ac5c80a8418d04436bff350f6bfe7a3 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 21 Jul 2016 11:38:44 +0200 Subject: [PATCH] [api] json loading with script to allow loading of utf-8 scripts with control characters --- grapheneapi/graphenewsrpc.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/grapheneapi/graphenewsrpc.py b/grapheneapi/graphenewsrpc.py index d057aee0..884dbe72 100644 --- a/grapheneapi/graphenewsrpc.py +++ b/grapheneapi/graphenewsrpc.py @@ -71,10 +71,8 @@ def wsconnect(self): self.ws = create_connection(self.url) break except KeyboardInterrupt: - print("Cought key interrupt!") - sys.exit(1) - except Exception as e: - print(e) + raise + except: if (self.num_retries >= 0 and cnt > self.num_retries): raise NumRetriesReached() @@ -312,10 +310,7 @@ def rpcexec(self, payload): reply = self.ws.recv() break except KeyboardInterrupt: - print("Cought key interrupt!") - sys.exit(1) -# except WebSocketConnectionClosedException: -# sys.exit(1) + raise except: if (self.num_retries > -1 and cnt > self.num_retries): @@ -336,7 +331,7 @@ def rpcexec(self, payload): ret = {} try: - ret = json.loads(reply) + ret = json.loads(reply, strict=False) except ValueError: raise ValueError("Client returned invalid format. Expected JSON!")