def dump_build_page(json_path, toolchain, jinja, out_dir, args, results_list): try: with open(json_path) as f: data = json.load(f) post_processed_schema(data) template = jinja.get_template("build.jinja.html") data["toolchain"] = toolchain data["name"] = os.path.basename(data["build_name"]) data["time"] = s_to_hhmmss(data["time"]) data["errors"] = get_errors(data["log"]) data["blocks"] = [os.path.basename(b) for b in data["blocks"]] data["blocked_by"] = [os.path.basename(b) for b in data["blocked_by"]] html = template.render(data=data) out_path = os.path.join(out_dir, "%s.html" % os.path.basename(data["build_name"])) with open(out_path, "w") as f: f.write(html.encode("utf-8")) # We now want to return this build to the top-level so that it # can generate summary pages of all builds. There is no need to # keep the build log for the summary, and it uses a lot of # memory, so remove it from the data structure. data.pop("log", None) data.pop("bear_output", None) results_list.append(data) except voluptuous.MultipleInvalid as e: sys.stderr.write("%s: Post-processed data is malformed: %s\n" % (json_path, str(e))) exit(1) except Exception as e: # Running in a separate process suppresses stack trace dump by # default, so do it manually traceback.print_exc(file=sys.stderr) raise e
def load_and_process(path, patterns, out_dir, args, boring_list): try: """Processes a JSON result file at path.""" with open(path) as f: data = json.load(f) if data["bootstrap"]: return if args.validate: try: make_package_schema(data) except voluptuous.MultipleInvalid as e: logging.error("Malformed input at %s\n %s" % (path, str(e))) return try: data = process_single_result(data, patterns, boring_list, args) except RuntimeError as e: logging.exception("Error for '%s'" % path) return if args.validate: try: post_processed_schema(data) except voluptuous.MultipleInvalid as e: logging.error("Post-processed data is malformatted: " "%s\n %s" % (path, str(e))) except RuntimeError as e: # Occasionally the process graph is so huge that it exceeds # Python's recursion depth limit. logging.exception("Error for '%s'" % path) with open(os.path.join(out_dir, os.path.basename(path)), "w") as fh: json.dump(data, fh, indent=2) except Exception as e: traceback.print_exc() exit(1)
def load_and_process(path, patterns, out_dir, args): """Processes a JSON result file at path.""" with open(path) as f: data = json.load(f) if data["bootstrap"]: return try: make_package_schema(data) except voluptuous.MultipleInvalid as e: logging.error("Malformed input at %s\n %s" % (path, str(e))) return data = process_single_result(data, patterns) try: post_processed_schema(data) except voluptuous.MultipleInvalid as e: logging.error("Post-processed data is malformatted: %s\n %s" % (path, str(e))) with open(os.path.join(out_dir, os.path.basename(path)), "w") as fh: json.dump(data, fh, indent=2)
def dump_build_page(json_path, toolchain, jinja, out_dir, args, results_list): try: with open(json_path) as f: data = json.load(f) if args.validate: post_processed_schema(data) # First, dump the process tree tree = list_of_process_tree(data["red_output"]) template = jinja.get_template("build_tree.html.jinja") html = template.render(build_name=os.path.basename(data["build_name"]), tree=tree, toolchain=data["toolchain"]) tree_path = os.path.join( out_dir, "%s-tree.html" % os.path.basename(data["build_name"])) with open(tree_path, "w") as f: f.write(html.encode("utf-8")) # Now, the build log. Link to the process tree. template = jinja.get_template("build.jinja.html") data["toolchain"] = toolchain data["name"] = os.path.basename(data["build_name"]) data["time"] = s_to_hhmmss(data["time"]) data["errors"] = get_errors(data["log"]) data["blocks"] = [os.path.basename(b) for b in data["blocks"]] data["blocked_by"] = [os.path.basename(b) for b in data["blocked_by"]] data["tree_path"] = os.path.basename(tree_path) data["sloc_ordered"] = [(k, v) for k, v in data["sloc_info"].items()] data["sloc_ordered"] = sorted(data["sloc_ordered"], key=lambda p: -1 * p[1]) total_sloc = 0 tmp = [] for (k, v) in data["sloc_ordered"]: total_sloc += v tmp.append((k, "{:,d}".format(v))) data["sloc_ordered"] = tmp data["total_sloc"] = "{:,d}".format(total_sloc) html = template.render(data=data) out_path = os.path.join( out_dir, "%s.html" % os.path.basename(data["build_name"])) with open(out_path, "w") as f: f.write(html.encode("utf-8")) # We now want to return this build to the top-level so that it # can generate summary pages of all builds. There is no need to # keep the build log for the summary, and it uses a lot of # memory, so remove it from the data structure. data.pop("log", None) data.pop("red_output", None) results_list.append(data) except voluptuous.MultipleInvalid as e: sys.stderr.write("%s: Post-processed data is malformed: %s\n" % (json_path, str(e))) exit(1) except Exception as e: # Running in a separate process suppresses stack trace dump by # default, so do it manually sys.stderr.write("Exception when processing '%s'\n" % json_path) traceback.print_exc(file=sys.stderr) return