Revision b77acb3e lib/luxi.py
b/lib/luxi.py | ||
---|---|---|
68 | 68 |
"""Decoding failure on the receiving side""" |
69 | 69 |
|
70 | 70 |
|
71 |
class RequestError(ProtocolError): |
|
72 |
"""Error on request |
|
73 |
|
|
74 |
This signifies an error in the request format or request handling, |
|
75 |
but not (e.g.) an error in starting up an instance. |
|
76 |
|
|
77 |
Some common conditions that can trigger this exception: |
|
78 |
- job submission failed because the job data was wrong |
|
79 |
- query failed because required fields were missing |
|
80 |
|
|
81 |
""" |
|
82 |
|
|
83 |
|
|
71 | 84 |
def SerializeJob(job): |
72 | 85 |
"""Convert a job description to a string format. |
73 | 86 |
|
... | ... | |
252 | 265 |
|
253 | 266 |
def SubmitJob(self, job): |
254 | 267 |
"""Submit a job""" |
255 |
return self.SendRequest(REQ_SUBMIT, SerializeJob(job)) |
|
268 |
result = self.SendRequest(REQ_SUBMIT, SerializeJob(job)) |
|
269 |
if not result['success']: |
|
270 |
raise RequestError(result['result']) |
|
271 |
return result['result'] |
|
256 | 272 |
|
257 | 273 |
def Query(self, data): |
258 | 274 |
"""Make a query""" |
259 |
return self.SendRequest(REQ_QUERY, data) |
|
275 |
result = self.SendRequest(REQ_QUERY, data) |
|
276 |
if not result['success']: |
|
277 |
raise RequestError(result[result]) |
|
278 |
result = result['result'] |
|
279 |
if data["object"] == "jobs": |
|
280 |
# custom job processing of query values |
|
281 |
for row in result: |
|
282 |
for idx, field in enumerate(data["fields"]): |
|
283 |
if field == "op_list": |
|
284 |
row[idx] = [opcodes.OpCode.LoadOpCode(i) for i in row[idx]] |
|
285 |
return result |
Also available in: Unified diff