mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Show docker build errors (#6695)
This commit is contained in:
parent
4443417c75
commit
30e39e85d0
@ -156,11 +156,13 @@ class RollingLogger:
|
||||
max_lines: int
|
||||
char_limit: int
|
||||
log_lines: list[str]
|
||||
all_lines: str
|
||||
|
||||
def __init__(self, max_lines=10, char_limit=80):
|
||||
self.max_lines = max_lines
|
||||
self.char_limit = char_limit
|
||||
self.log_lines = [''] * self.max_lines
|
||||
self.all_lines = ''
|
||||
|
||||
def is_enabled(self):
|
||||
return DEBUG and sys.stdout.isatty()
|
||||
@ -175,6 +177,7 @@ class RollingLogger:
|
||||
self.log_lines.pop(0)
|
||||
self.log_lines.append(line[: self.char_limit])
|
||||
self.print_lines()
|
||||
self.all_lines += line + '\n'
|
||||
|
||||
def write_immediately(self, line):
|
||||
self._write(line)
|
||||
|
||||
@ -168,8 +168,10 @@ class DockerRuntimeBuilder(RuntimeBuilder):
|
||||
)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f'Image build failed:\n{e}')
|
||||
logger.error(f'Image build failed:\n{e}') # TODO: {e} is empty
|
||||
logger.error(f'Command output:\n{e.output}')
|
||||
if self.rolling_logger.is_enabled():
|
||||
logger.error("Docker build output:\n" + self.rolling_logger.all_lines) # Show the error
|
||||
raise
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user