Commit a14a17fc authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent 00abdc96
......@@ -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):
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment