Return the results from master_tops if configured
964772
def _master_tops(self, load, skip_verify=False):
        '''
        
        '''
        if not skip_verify:
            if 'id' not in load:
                log.error('Received call for external nodes without an id')
                return {}
            if not salt.utils.verify.valid_id(self.opts, load['id']):
                return {}
        # Evaluate all configured master_tops interfaces

        opts = {}
        grains = {}
        ret = {}

        if 'opts' in load:
            opts = load['opts']
            if 'grains' in load['opts']:
                grains = load['opts']['grains']
        for fun in self.tops:
            if fun not in self.opts.get('master_tops', {}):
                continue
            try:
                ret = salt.utils.dictupdate.merge(ret, self.tops[fun](opts=opts, grains=grains), merge_lists=True)
            except Exception as exc:
                # If anything happens in the top generation, log it and move on
                log.error(
                    'Top function %s failed with error %s for minion %s',
                    fun, exc, load['id']
                )
        return ret
1115791
def cache_results(&block)
        if template_cache_configured? && Rabl.configuration.cache_all_output && @_object.respond_to?(:cache_key)
          cache_key = [@_object, @options[:root_name], @options[:format]]

          fetch_result_from_cache(cache_key, &block)
        else # skip cache
          yield
        end
      end
435695
def get_top(self):
        '''
        
        '''
        tops, errors = self.get_tops()
        try:
            merged_tops = self.merge_tops(tops)
        except TypeError as err:
            merged_tops = OrderedDict()
            errors.append('Error encountered while rendering pillar top file.')
        return merged_tops, errors
974337
def top(**kwargs):
    '''
    
    '''
    if 'id' not in kwargs['opts']:
        return {}
    cmd = '{0} {1}'.format(
            __opts__['master_tops']['ext_nodes'],
            kwargs['opts']['id']
            )
    ndata = salt.utils.yaml.safe_load(
        subprocess.Popen(
            cmd,
            shell=True,
            stdout=subprocess.PIPE).communicate()[0]
    )
    if not ndata:
        log.info('master_tops ext_nodes call did not return any data')
    ret = {}
    if 'environment' in ndata:
        env = ndata['environment']
    else:
        env = 'base'

    if 'classes' in ndata:
        if isinstance(ndata['classes'], dict):
            ret[env] = list(ndata['classes'])
        elif isinstance(ndata['classes'], list):
            ret[env] = ndata['classes']
        else:
            return ret
    else:
        log.info('master_tops ext_nodes call did not have a dictionary with a "classes" key.')

    return ret
203876
def master_for( key )
      return if @masters.empty?
      key = to_key(key)

      loop do
        break key if @masters.include? key
        break nil if :root == key

        if index = key.rindex(PATH_DELIMITER)
          key = key.slice(0, index)
        else
          key = :root
        end
      end
    end
1180825
def show_top(queue=False, **kwargs):
    '''
    
    '''
    if 'env' in kwargs:
        # "env" is not supported; Use "saltenv".
        kwargs.pop('env')

    conflict = _check_queue(queue, kwargs)
    if conflict is not None:
        return conflict

    opts = salt.utils.state.get_sls_opts(__opts__, **kwargs)
    try:
        st_ = salt.state.HighState(opts,
                                   proxy=__proxy__,
                                   initial_pillar=_get_initial_pillar(opts))
    except NameError:
        st_ = salt.state.HighState(opts, initial_pillar=_get_initial_pillar(opts))

    errors = _get_pillar_errors(kwargs, pillar=st_.opts['pillar'])
    if errors:
        __context__['retcode'] = salt.defaults.exitcodes.EX_PILLAR_FAILURE
        raise CommandExecutionError('Pillar failed to render', info=errors)

    errors = []
    top_ = st_.get_top()
    errors += st_.verify_tops(top_)
    if errors:
        __context__['retcode'] = salt.defaults.exitcodes.EX_STATE_COMPILER_ERROR
        return errors
    matches = st_.top_matches(top_)
    return matches
355180
def stdout_to_results(s):
    """"""
    results = s.strip().split('\n')
    return [BenchmarkResult(*r.split()) for r in results]
1108159
def get_bios_settings_result(self):
        
        headers, bios_uri, bios_settings = self._check_bios_resource()
        settings_result = bios_settings.get("SettingsResult").get("Messages")
        status = "failed" if len(settings_result) > 1 else "success"
        return {"status": status, "results": settings_result}
867410
def top(self, sort_by):
        """"""
        sort = sorted(self.results, key=sort_by)
        return sort
1353796
def _get_top_states(saltenv='base'):
    '''
    
    '''
    alt_states = []
    try:
        returned = __salt__['state.show_top']()
        for i in returned[saltenv]:
            alt_states.append(i)
    except Exception:
        raise
    # log.info("top states: %s", alt_states)
    return alt_states
809570
def gather_master_data(stackname)
      response = fetch_master_data(stackname)
      children = response.delete('children') || []
      result = { stackname => { stack_data: response } }
      children.each do |child|
        result.merge!(gather_master_data(child['name']))
      end
      result
    end
558294
def collect_result(command, pid, host_stdout, host_stderr)
      result = CommandRunResult.new(pid, command, self)
      result.streams = {1 => host_stdout, 2 => host_stderr}
      return result
    end
1067086
def collect_results():
    
    results = []
    for exe, backendname in EXE_BACKEND_MATRIX:
        results.extend(benchmark_process_and_backend(exe, backendname))
    results.extend(benchmark_go())

    results.sort(
        key=lambda br: (br.benchmark, float(br.time), br.platform, br.backend))
    return results
559247
def get_results(self):
        
        return IterResult(self._loop(), self.name, self.argnames,
                          self.sent, self.monitor.hdf5)
224995
def get_top_gainers(self, as_json=False):
        
        url = self.top_gainer_url
        req = Request(url, None, self.headers)
        # this can raise HTTPError and URLError
        res = self.opener.open(req)
        # for py3 compat covert byte file like object to
        # string file like object
        res = byte_adaptor(res)
        res_dict = json.load(res)
        # clean the output and make appropriate type conversions
        res_list = [self.clean_server_response(item) for item in res_dict['data']]
        return self.render_response(res_list, as_json)
1017518
def results( self ):
        """"""
        rs = []
        for k in self._results.keys():
            # filter out pending job ids, which can be anything except dicts
            ars = [ res for res in self._results[k] if isinstance(res, dict) ]
            rs.extend(ars)
        return rs
838472
def master_for(self, service):
        """"""
        # TODO: make it coroutine and connect minsize connections
        if service not in self._masters:
            self._masters[service] = ManagedPool(
                self, service, is_master=True,
                db=self._redis_db,
                password=self._redis_password,
                encoding=self._redis_encoding,
                minsize=self._redis_minsize,
                maxsize=self._redis_maxsize,
                ssl=self._redis_ssl,
                parser=self._parser_class,
                loop=self._loop)
        return self._masters[service]