1
0
mirror of https://github.com/esphome/esphome.git synced 2025-07-05 06:33:31 +01:00

Consistently format errors in CI scripts ()

This commit is contained in:
Oxan van Leeuwen
2021-11-25 21:54:11 +01:00
committed by GitHub
parent 9681dfb458
commit 00965fe19e
8 changed files with 57 additions and 55 deletions

@ -1,7 +1,10 @@
#!/usr/bin/env python3
from helpers import print_error_for_file, get_output, filter_grep, \
build_all_include, temp_header_file, git_ls_files, filter_changed, load_idedata, basepath
import argparse
import json
import click
import colorama
import multiprocessing
import os
import queue
@ -12,13 +15,6 @@ import sys
import tempfile
import threading
import click
import pexpect
sys.path.append(os.path.dirname(__file__))
from helpers import shlex_quote, get_output, filter_grep, \
build_all_include, temp_header_file, git_ls_files, filter_changed, load_idedata, basepath
def clang_options(idedata):
cmd = [
@ -87,23 +83,20 @@ def run_tidy(args, options, tmpdir, queue, lock, failed_files):
invocation.append(name)
if args.quiet:
invocation.append('-quiet')
invocation.append('--quiet')
if sys.stdout.isatty():
invocation.append('--use-color')
invocation.append(os.path.abspath(path))
invocation.append(f"--header-filter={os.path.abspath(basepath)}/.*")
invocation.append(os.path.abspath(path))
invocation.append('--')
invocation.extend(options)
invocation_s = ' '.join(shlex_quote(x) for x in invocation)
# Use pexpect for a pseudy-TTY with colored output
output, rc = pexpect.run(invocation_s, withexitstatus=True, encoding='utf-8',
timeout=15 * 60)
if rc != 0:
proc = subprocess.run(invocation, capture_output=True, encoding='utf-8')
if proc.returncode != 0:
with lock:
print()
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(path))
print(output)
print()
print_error_for_file(path, proc.stdout)
failed_files.append(path)
queue.task_done()
@ -119,6 +112,8 @@ def split_list(a, n):
def main():
colorama.init()
parser = argparse.ArgumentParser()
parser.add_argument('-j', '--jobs', type=int,
default=multiprocessing.cpu_count(),