'Stores the results.'

@flow.StateHandler()
def StoreResults(self, responses):

    if (not responses.success):
        self.state.plugin_errors.append(unicode(responses.status.error_message))
    self.Log(('Rekall    returned    %s    responses.' % len(responses)))
    for response in responses:
        if response.missing_profile:
            profile = self.GetProfileByName(response.missing_profile, response.repository_version)
            if profile:
                self.CallClient(grr_rekall_stubs.WriteRekallProfile, profile, next_state='UpdateProfile')
            else:
                self.Log('Needed    profile    %s    not    found!    See    https://github.com/google/grr-doc/blob/master/troubleshooting.adoc#missing-rekall-profiles', response.missing_profile)
        if response.json_messages:
            response.client_urn = self.client_id
            if self.state.rekall_context_messages:
                response.json_context_messages = json.dumps(self.state.rekall_context_messages.items(), separators=(',', ':'))
            json_data = json.loads(response.json_messages)
            for message in json_data:
                if (len(message) >= 1):
                    if (message[0] in ['t', 's']):
                        self.state.rekall_context_messages[message[0]] = message[1]
                    if (message[0] == 'file'):
                        pathspec = rdf_paths.PathSpec(**message[1])
                        self.state.output_files.append(pathspec)
                    if (message[0] == 'L'):
                        if (len(message) > 1):
                            log_record = message[1]
                            self.Log('%s:%s:%s', log_record['level'], log_record['name'], log_record['msg'])
            self.SendReply(response)
    if (responses.iterator and (responses.iterator.state != rdf_client.Iterator.State.FINISHED)):
        self.state.rekall_request.iterator = responses.iterator
        self.CallClient(grr_rekall_stubs.RekallAction, self.state.rekall_request, next_state='StoreResults')
    elif self.state.output_files:
        self.Log('Getting    %i    files.', len(self.state.output_files))
        self.CallFlow(transfer.MultiGetFile.__name__, pathspecs=self.state.output_files, file_size=self.args.max_file_size_download, next_state='DeleteFiles')
