def apply_cpu_to_traces()

in uberpoet/commandlineutil.py [0:0]


def apply_cpu_to_traces(build_trace_path, cpu_logger, time_cutoff=None):
    logging.info('Applying CPU info to traces in %s', build_trace_path)
    cpu_logs = cpu_logger.process_log()
    trace_paths = [join(build_trace_path, f) for f in os.listdir(build_trace_path) if f.endswith('trace')]
    for trace_path in trace_paths:
        if time_cutoff and os.path.getmtime(trace_path) < time_cutoff:
            continue
        with open(trace_path, 'r') as trace_file:
            traces = json.load(trace_file)
            new_traces = CPULog.apply_log_to_trace(cpu_logs, traces)
        with open(trace_path + '.json', 'w') as new_trace_file:
            json.dump(new_traces, new_trace_file)