def RunMetric(filename, metric, extra_import_options=None):
    th = file_handle.URLFileHandle(filename, 'file://' + filename)
    result = map_single_trace.MapSingleTrace(th,
                                             _GetMetricRunnerHandle(metric),
                                             extra_import_options)

    return result
def RunMetricOnTraces(filenames, metric, extra_import_options=None):
    trace_handles = [
        file_handle.URLFileHandle(f, 'file://%s' % f) for f in filenames
    ]
    job = _GetMetricRunnerHandle(metric)
    runner = map_runner.MapRunner(
        trace_handles,
        job,
        extra_import_options=extra_import_options,
        progress_reporter=progress_reporter.ProgressReporter())
    map_results = runner.RunMapper()
    return map_results
Exemple #3
0
 def _ConvertResultsToFileHandlesAndKeys(self, results_list):
     handles_and_keys = []
     for current_result in results_list:
         _, path = tempfile.mkstemp()
         with open(path, 'w') as results_file:
             json.dump(current_result.AsDict(), results_file)
         rh = file_handle.URLFileHandle(path, 'file://' + path)
         handles_and_keys.append({
             'handle': rh,
             'keys': current_result.pairs.keys()
         })
     return handles_and_keys
  def GetTraceHandlesMatchingQuery(self, query):
    trace_handles = []

    files = _GetFilesIn(self.directory)
    for rel_filename in files:
      filename = os.path.join(self.directory, rel_filename)
      metadata = _GetMetadataForFilename(self.directory, filename)

      if not query.Eval(metadata, len(trace_handles)):
        continue

      url = self.url_resolver(filename)
      if url is None:
        url = _DefaultUrlResover(filename)

      th = file_handle.URLFileHandle(url, 'file://' + filename)
      trace_handles.append(th)

    return trace_handles
def _ProcessTracesWithMapper(mapper_handle_str, traces, output_file):
    map_handle = function_handle.FunctionHandle.FromUserFriendlyString(
        mapper_handle_str)
    job = job_module.Job(map_handle)

    trace_handles = [
        file_handle.URLFileHandle(f, 'file://%s' % f) for f in traces
    ]

    runner = map_runner.MapRunner(
        trace_handles,
        job,
        progress_reporter=progress_reporter.ProgressReporter())

    results = runner.RunMapper()
    results_dict = {k: v.AsDict() for k, v in results.iteritems()}
    _DumpToOutputJson(results_dict, output_file)

    return _GetExitCodeForResults(results)
Exemple #6
0
def RunMetrics(filename, metrics):
    th = file_handle.URLFileHandle(filename, 'file://' + filename)
    result = map_single_trace.MapSingleTrace(th,
                                             _GetMetricRunnerHandle(metrics))

    return result