def display_check_results(results, out): s = "" s += f"\n{len(results)} results to report" for i, r in enumerate(results): s += "\n" + dtu.indent(str(r), "", f"{i + 1} of {len(results)}: ") print(s) fn = os.path.join(out, "check_results.txt") dtu.write_str_to_file(s, fn)
def write_candidate_cloud(logs): cache_dir = dtu.get_duckietown_cache_dir() fn = os.path.join(cache_dir, "candidate_cloud.yaml") s = yaml_representation_of_phy_logs(logs) dtu.write_str_to_file(s, fn) # try reading dtu.logger.info("reading back logs") logs2 = logs_from_yaml(dtu.yaml_load_plain(s)) dtu.logger.info(f"read back {len(logs2)}")
def run_one(cmd): v = False cwd = dtu.get_output_dir_for_test() if not os.path.exists(cwd): dtu.mkdirs_thread_safe(cwd) dtu.write_str_to_file("config echo 1", os.path.join(cwd, ".compmake.rc")) try: dtu.system_cmd_result(cwd, cmd, display_stdout=v, display_stderr=v, raise_on_error=True) finally: pass
def create_report_html(log_name, filenames, out): html = Tag(name="html") body = Tag(name="body") head = Tag(name="head") link = Tag(name="link") link.attrs["type"] = "text/css" link.attrs["rel"] = "stylesheet" link.attrs["href"] = "style.css" title = Tag(name="title") title.append("Report") head.append(link) html.append(head) h = Tag(name="h1") h.append(f"Report for {log_name}") body.append(h) for f in filenames: f = os.path.realpath(f) out = os.path.realpath(out) d = os.path.dirname(out) rel = os.path.relpath(f, d) p = Tag(name="p") if ".jpg" in f or ".png" in f: img = Tag(name="img") img.attrs["src"] = rel p.append(img) if ".mp4" in f: v = video_for_source(rel) p.append(v) body.append(p) html.append(body) s = str(html) dtu.write_str_to_file(s, out)
def go(self): extra = self.options.get_extra() Gallery.deploy_ipfs = self.options["ipfs"] if not extra: query = "*" else: query = extra db = self.get_easy_logs_db() logs = db.query(query) logs_valid = {} ninvalid = 0 length_invalid = 0.0 for log_name, log in list(logs.items()): if log.valid: logs_valid[log_name] = log else: ninvalid += 1 if log.length is not None: length_invalid += log.length logs = logs_valid self.info(f"Found {len(logs)} valid logs.") s = format_logs(logs) self.info(s) res = get_report(logs) out = self.options["destination"] fn_html = os.path.join(out, "index.html") dtu.write_str_to_file(res, fn_html)
def print_results(analyzers: List[str], results_all, out: str): base = os.path.join(out, "statistics") yaml_data = dtu.yaml_dump_pretty(results_all) dtu.write_str_to_file(yaml_data, os.path.join(base, "statistics.yaml")) print((dtu.indent(yaml_data, "print_results "))) for a in analyzers: dtu.write_str_to_file(dtu.yaml_dump_pretty(results_all[a]), os.path.join(base, f"{a}.table.yaml")) s = "" s += "\n" + "-" * 10 + f" Results for {a} " + "-" * 10 table = table_for_analyzer(results_all[a]) s += "\n" + dtu.indent(dtu.format_table_plus(table, colspacing=3), " ") s += "\n" dtu.write_str_to_file(s, os.path.join(base, f"{a}.table.txt"))
def write_to_db(rt_name, results_all, out): rdbe = make_entry(rt_name, results_all) fn = get_unique_filename(rt_name, rdbe) s = yaml_from_rdbe(rdbe) filename = os.path.join(out, fn) dtu.write_str_to_file(s, filename)