Evaluate a storm query and yield result messages.
        Yields:
            ((str,dict)): Storm messages.
176496
async def streamstorm(self, text, opts=None, user=None):
        '''
        
        '''
        if opts is None:
            opts = {}

        MSG_QUEUE_SIZE = 1000
        chan = asyncio.Queue(MSG_QUEUE_SIZE, loop=self.loop)

        if user is None:
            user = self.auth.getUserByName('root')

        # promote ourself to a synapse task
        synt = await self.boss.promote('storm', user=user, info={'query': text})

        show = opts.get('show')

        async def runStorm():
            cancelled = False
            tick = s_common.now()
            count = 0
            try:
                # First, try text parsing. If this fails, we won't be able to get
                # a storm runtime in the snap, so catch and pass the `err` message
                # before handing a `fini` message along.
                self.getStormQuery(text)

                await chan.put(('init', {'tick': tick, 'text': text, 'task': synt.iden}))

                shownode = (show is None or 'node' in show)
                async with await self.snap(user=user) as snap:

                    if show is None:
                        snap.link(chan.put)

                    else:
                        [snap.on(n, chan.put) for n in show]

                    if shownode:
                        async for pode in snap.iterStormPodes(text, opts=opts, user=user):
                            await chan.put(('node', pode))
                            count += 1

                    else:
                        async for item in snap.storm(text, opts=opts, user=user):
                            count += 1

            except asyncio.CancelledError:
                logger.warning('Storm runtime cancelled.')
                cancelled = True
                raise

            except Exception as e:
                logger.exception('Error during storm execution')
                enfo = s_common.err(e)
                enfo[1].pop('esrc', None)
                enfo[1].pop('ename', None)
                await chan.put(('err', enfo))

            finally:
                if cancelled:
                    return
                tock = s_common.now()
                took = tock - tick
                await chan.put(('fini', {'tock': tock, 'took': took, 'count': count}))

        await synt.worker(runStorm())

        while True:

            mesg = await chan.get()

            yield mesg

            if mesg[0] == 'fini':
                break
963211
def _result_handler(self, response: Dict[str, Any]):
        
        res = response.get("MESSAGE")
        result = res.get("RESULT")
        return result
435395
def objects(self, json_result=False):
        
        self.rows_num = 0
        query = self.query()
        if not isinstance(query, (orm.Result, list, dict)):
            query = do_(query)
        for record in query:
            self.rows_num += 1
            r = self.object(record, json_result)
            self._cal_sum(record)
            yield r
        total = self._render_sum(True)
        if total:
            yield total
559247
def get_results(self):
        
        return IterResult(self._loop(), self.name, self.argnames,
                          self.sent, self.monitor.hdf5)
1243033
def messages(self):
        ''''''

        # the file contains the fixed-size file header followed by
        # fixed-size message structures. start after the file header and
        # then simply return the message structures in sequence until the
        # end of the file.

        offset = self.LENGTH
        while offset < len(self.mmap):
            yield Message(mm=self.mmap, offset=offset)
            offset += Message.LENGTH
1269106
def get_items(self, sequence_id, gt=None, gte=None, lt=None, lte=None, limit=None,
                  query_ascending=True, results_ascending=True):
        
        records = self.get_records(
            sequence_id=sequence_id,
            gt=gt,
            gte=gte,
            lt=lt,
            lte=lte,
            limit=limit,
            query_ascending=query_ascending,
            results_ascending=results_ascending,

        )
        for item in map(self.from_record, records):
            yield item
725995
def build_messages_modules(messages):
    
    data = collections.defaultdict(list)
    for line in messages:
        module_name = line.get('module')
        module_path = line.get('path')
        module_info = ModuleInfo(
            module_name,
            module_path,
        )
        data[module_info].append(line)

    for module, module_messages in data.items():
        yield (
            module,
            sorted(module_messages, key=lambda x: x.get('line')))
326316
async def eval(self, text, opts=None):
        '''
        
        '''
        async for pode in self.cell.iterStormPodes(text, opts=opts, user=self.user):
            yield pode
259043
def yield_from_handle(self, tokens):
        """"""
        internal_assert(len(tokens) == 1, "invalid yield from tokens", tokens)
        if self.target_info < (3, 3):
            return (
                yield_from_var + " = " + tokens[0]
                + "\nfor " + yield_item_var + " in " + yield_from_var + ":\n"
                + openindent + "yield " + yield_item_var + "\n" + closeindent
            )
        else:
            return "yield from " + tokens[0]
627635
def get_results(self):
        
        try:
            stdout, stderr = self._lint()
            # Can't return a generator from a subprocess
            return list(stdout), stderr or []
        except FileNotFoundError as exception:
            # Error if the linter was not found but was chosen by the user
            if self._linter.name in self.config.user_linters:
                error_msg = 'Could not find {}. Did you install it? ' \
                    'Got exception: {}'.format(self._linter.name, exception)
                return [[], [error_msg]]
            # If the linter was not chosen by the user, do nothing
            return [[], []]
1194147
def iteritems(self, **options):
        ''''''
        iter = self.query(**options)
        while True:
            obj = iter.next()
            yield (obj.id, obj)
970714
def filter(self, **kwargs):
        '''
        '''
        # So we don't return anything more than once.
        yielded = set()

        dunder = '__'
        filter_items = set()
        for k, v in kwargs.items():
            if dunder in k:
                k, op = k.split(dunder)
                try:
                    handler = getattr(self, 'handle__%s' % op)
                except AttributeError:
                    msg = '%s has no %r method to handle operator %r.'
                    raise NonExistentHandler(msg % (self, handler, op))
                for dicty in self:
                    if handler(k, v, dicty):
                        dicty_id = id(dicty)
                        if dicty_id not in yielded:
                            yield dicty
                            yielded.add(dicty_id)
            else:
                filter_items.add((k, v))

        for dicty in self:
            dicty_items = set(dicty.items())
            if filter_items.issubset(dicty_items):
                yield dicty
205830
def get_failed_requests(self, results):
        
        data = {member['guid']: member for member in results}
        for request in self.requests:
            if request['guid'] not in data:
                yield request
897344
def generator(self, response):
        

        delim = '\t'  # Default to tab delimited
        columns = []
        response.raw.decode_content = True
        events = ET.iterparse(BytesIO(response.content))

        results = []
        for event, elem in events:
            # Analyze search record data
            if "DATA" == elem.tag:
                data_dict = {column: data for column, data in zip(columns, elem.text.split(delim)) if column != ''}
                self.parsed_rows += 1  # Rows parsed with all requests
                results.append(data_dict)

            # Handle reply code
            elif "RETS" == elem.tag:
                reply_code = elem.get('ReplyCode')
                reply_text = elem.get('ReplyText')

                if reply_code == '20201':
                    # RETS Response 20201 - No Records Found
                    # Generator should continue and return nothing
                    continue
                elif reply_code != '0':
                    msg = "RETS Error {0!s}: {1!s}".format(reply_code, reply_text)
                    raise RETSException(msg)

            # Analyze delimiter
            elif "DELIMITER" == elem.tag:
                val = elem.get("value")
                delim = chr(int(val))

            # Analyze columns
            elif "COLUMNS" == elem.tag:
                columns = elem.text.split(delim)

            # handle max rows
            elif "MAXROWS" == elem.tag:
                logger.debug("MAXROWS Tag reached in XML")
                logger.debug("Received {0!s} results from this search".format(self.parsed_rows))
                raise MaxrowException(results)

            else:
                # This is a tag we don't process (like COUNT)
                continue

            elem.clear()

        return results
182188
def run(self):
        """"""
        for msg in self.messages:
            col = getattr(msg, 'col', 0)
            yield msg.lineno, col, (msg.tpl % msg.message_args), msg.__class__
876652
def results(self):
        """"""
        tt = None
        for i, tf in enumerate(self[:-1]):
            tt = self[i+1]
            q = Queue(tf.qsize)
            tf.set_out(q, tt.workers)
            tt.set_in(q, tf.workers)

        if tt is None: # we have only one pool
            tt = self[0]
        q = Queue(tt.qsize)
        err_q = Queue()
        tt.set_out(q, 1)

        for t in self:
            t.set_err(err_q)
            t._start()

        for item in iterqueue(q, tt.workers):
            yield item

        errors = list(iterqueue(err_q, sum(t.workers for t in self)))

        for t in self:
            t._join()

        if len(errors) > 0:
            task_name, ex = errors[0]
            if len(errors) == 1:
                msg = 'The task "%s" raised %s' % (task_name, repr(ex),)
            else:
                msg = '%d tasks raised an exeption. First error reported on task "%s": %s' % (len(errors), task_name, repr(ex))

            raise TaskException(msg)
1009130
def message_handlers(self):
        """"""
        index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, 0)

        while index != 0:
            yield MessageHandler(self._env, self._cls, index)

            index = lib.EnvGetNextDefmessageHandler(self._env, self._cls, index)