@@ -0,0 +1,2220 @@
+#!/usr/bin/python3%0A#%0A# Copyright (C) 2016 The Android Open Source Project%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#      http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0Aimport sys%0A%0Adef usage():%0A    print(%22%22%22USAGE:%0A    Simplifies a build.log from hundreds of megabytes to %3C100 lines. Prints output to terminal.%0A    Pass this script a filepath to parse. You should be able to type %22python3 build_log_simplifier.py%22%0A    And then drag-and-drop a log file onto the terminal window to get its path.%0A%0A    Sample usage: python3 development/build_log_simplifier.py Users/owengray/Desktop/build.log%0A    %22%22%22)%0A    exit(1)%0A%0Atry:%0A    build_log_loc = sys.argv%5B1%5D%0A%0A    infile = open(build_log_loc)%0A%0A    tasks_of_interest = %5B%5D%0A%0A    # first, find tasks of interest%0A    for line in infile:%0A        if line.startswith(%22Execution failed for task%22):%0A            tasks_of_interest.append(line.split(%22task '%22)%5B1%5D%5B:-3%5D)%0A%0A    infile.close()%0A    infile = open(build_log_loc)%0A%0A    print(%22Tasks of interest: %22 + str(tasks_of_interest))%0A%0A    # next, save all excerpts between start(interesting task) and end(interesting task)%0A    current_interesting_tasks = %5B%5D%0A    retained_lines = %5B%5D%0A    for line in infile:%0A        if line.startswith(%22Task %22) and line.split(%22 %22)%5B1%5D in tasks_of_interest:%0A            if line.split(%22 %22)%5B-1%5D.strip() == %22Starting%22:%0A                current_interesting_tasks.append(line.split(%22 %22)%5B1%5D)%0A            elif line.split(%22 %22)%5B-1%5D.strip() == %22Finished%22:%0A                current_interesting_tasks.remove(line.split(%22 %22)%5B1%5D)%0A                retained_lines.append(line)%0A        if current_interesting_tasks: retained_lines.append(line)%0A%0A%0A    print(len(retained_lines))%0A    print(''.join(retained_lines))%0Aexcept Exception as e:%0A    print(%22An error occurred! %22+str(e))%0A    usage()

Add a script for simplifying build.log files