From a14a17fc7a345dd6caa35ff17cd957a6e9e2d60b Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 7 Apr 2008 11:15:41 +0000 Subject: [PATCH] Move some checks from cli.py to luxi.py The idea of cli.py and luxi.py is that all protocol checks should be in luxi, and cli.py should just offer some helpful shortcuts for the command line scripts. This patch removes the result checks from cli and adds some other checks to luxi. It does no longer check the success/failure since it's not yet clear how that should be handled - probably exceptions. Reviewed-by: ultrotter --- lib/cli.py | 8 ++------ lib/luxi.py | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index c3780380b..31bc0b7cc 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -391,17 +391,13 @@ def SubmitOpCode(op, proc=None, feedback_fn=None): def SubmitJob(job, cl=None): if cl is None: cl = luxi.Client() - jid = cl.SubmitJob(job) - return jid + return cl.SubmitJob(job) def SubmitQuery(data, cl=None): if cl is None: cl = luxi.Client() - result = cl.Query(data) - if not result['success']: - raise ValueError(result) - return result['result'] + return cl.Query(data) def FormatError(err): diff --git a/lib/luxi.py b/lib/luxi.py index 785543467..5944a43d4 100644 --- a/lib/luxi.py +++ b/lib/luxi.py @@ -244,6 +244,10 @@ class Client(object): data = simplejson.loads(result) except Exception, err: raise ProtocolError("Error while deserializing response: %s" % str(err)) + if (not isinstance(data, dict) or + 'success' not in data or + 'result' not in data): + raise DecodingError("Invalid response from server: %s" % str(data)) return data def SubmitJob(self, job): -- GitLab