Handle missing command.

This commit is contained in:
Jelmer Vernooij 2021-03-17 04:39:34 +00:00
parent 9635b68648
commit 14e3726ae8

View file

@ -20,6 +20,7 @@ from typing import List, Optional
from buildlog_consultant.common import ( from buildlog_consultant.common import (
find_build_failure_description, find_build_failure_description,
MissingCommand,
) )
from breezy.mutabletree import MutableTree from breezy.mutabletree import MutableTree
@ -66,18 +67,22 @@ def run_with_build_fixers(session: Session, args: List[str], fixers: List[BuildF
logging.info("Running %r", args) logging.info("Running %r", args)
fixed_errors = [] fixed_errors = []
while True: while True:
retcode, contents = run_with_tee(session, args) try:
if retcode == 0: retcode, contents = run_with_tee(session, args)
return except FileNotFoundError as e:
lines = ''.join(contents).splitlines(True) error = MissingCommand(e.args[0])
match, error = find_build_failure_description(lines) else:
if error is None: if retcode == 0:
if match: return
logging.warning("Build failed with unidentified error:") lines = ''.join(contents).splitlines(True)
logging.warning("%s", match.line.rstrip("\n")) match, error = find_build_failure_description(lines)
else: if error is None:
logging.warning("Build failed and unable to find cause. Giving up.") if match:
raise UnidentifiedError(retcode, args, lines, secondary=match) logging.warning("Build failed with unidentified error:")
logging.warning("%s", match.line.rstrip("\n"))
else:
logging.warning("Build failed and unable to find cause. Giving up.")
raise UnidentifiedError(retcode, args, lines, secondary=match)
logging.info("Identified error: %r", error) logging.info("Identified error: %r", error)
if error in fixed_errors: if error in fixed_errors: