From 5ac5df42a0f8e2ca3952ea86897756acdb402a84 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sat, 1 Mar 2025 14:58:15 +0100 Subject: [PATCH] made a better clean of the output --- clone_repos.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/clone_repos.py b/clone_repos.py index 087194d..9157e94 100644 --- a/clone_repos.py +++ b/clone_repos.py @@ -1,5 +1,5 @@ import pandas as pd -import argparse, os, sys, subprocess, docker +import argparse, os, sys, subprocess, docker, re from tqdm import tqdm import shutil @@ -137,10 +137,20 @@ def remove_dir(dir: str) -> None: shutil.rmtree(parent) def clean_output(output: bytes) -> str: - output_str = output.decode() - def _keep(line): - return not (line.startswith("Download") or line.startswith("Progress")) - return "\n".join([line for line in output_str.split("\n") if _keep(line)]) + output_lines = output.decode().split("\n") + cleaned_lines = [] + downloading_block = False + + for line in output_lines: + if re.match(r"\[INFO\] Download(ing|ed) from", line): + if not downloading_block: + cleaned_lines.append("[CRAB] Downloading stuff") + downloading_block = True + else: + cleaned_lines.append(line) + downloading_block = False + + return "\n".join(cleaned_lines) def compile_repo(build_file: str, container, updates: dict) -> bool: """