def jobret(job): ''' Return job result or raise on error. Example: return jobret(job) ''' err = job[1].get('err') # populate errinfo into SynErr info = job[1].get('errinfo') if info is None: info = {} if err is not None: if err != 'NameErr': try: info = job[1].get('errinfo', {}) raise s_common.synerr(err, **info) except NameError as e: pass raise s_common.JobErr(job) return job[1].get('ret')
def eval(self, text, data=(), timeout=None): ''' Run a storm query and return only the result data. Example: for tufo in runt.eval('foo:bar=10 +foo:baz<30'): dostuff(tufo) ''' answ = self.ask(text, data=data, timeout=timeout) oplog = answ.get('oplog') if oplog: excinfo = oplog[-1].get('excinfo') if excinfo is not None: errname = excinfo.get('err') errinfo = excinfo.get('errinfo', {}) errinfo['errfile'] = excinfo.get('errfile') errinfo['errline'] = excinfo.get('errline') raise s_common.synerr(errname, **errinfo) return answ.get('data')