Skip to content

Commit 2a23fa0

Browse files
committed
chore: improve error handling for console rich output
Signed-off-by: Demolus13 <parth.govale@oracle.com>
1 parent 2ab5e4e commit 2a23fa0

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

src/macaron/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ def main(argv: list[str] | None = None) -> None:
719719
if args.disable_rich_output:
720720
st_handler.close()
721721
else:
722+
rich_handler.mark_failed()
722723
rich_handler.close()
723724

724725

src/macaron/console.py

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ def update_checks_summary(self, checks_summary: dict, total_checks: int) -> None
154154
self.failed_checks_table = self._make_failed_checks_table(checks_summary.get("FAILED", []))
155155
self.summary_table = self._make_summary_table(checks_summary, total_checks)
156156

157+
def mark_failed(self) -> None:
158+
"""Convert any Processing Status entries to Failed."""
159+
for key, value in self.description_table_content.items():
160+
if str(value) == "Processing":
161+
self.description_table_content[key] = "[red]Failed[/red]"
162+
163+
self.description_table = self._make_table(self.description_table_content, ["Details", "Value"])
164+
157165
def make_layout(self) -> list[RenderableType]:
158166
"""
159167
Create the layout for the live console display.
@@ -505,12 +513,7 @@ def update_find_source_table(self, key: str, value: str | Status) -> None:
505513
The value associated with the key.
506514
"""
507515
self.find_source_content[key] = value
508-
find_source_table = Table(show_header=False, box=None)
509-
find_source_table.add_column("Details", justify="left")
510-
find_source_table.add_column("Value", justify="left")
511-
for field, content in self.find_source_content.items():
512-
find_source_table.add_row(field, content)
513-
self.find_source_table = find_source_table
516+
self.find_source_table = self._make_table(self.find_source_content, ["Details", "Value"])
514517

515518
def update_dump_defaults(self, value: str | Status) -> None:
516519
"""
@@ -535,12 +538,31 @@ def update_gen_build_spec(self, key: str, value: str | Status) -> None:
535538
The value associated with the key.
536539
"""
537540
self.gen_build_spec[key] = value
538-
gen_build_spec_table = Table(show_header=False, box=None)
539-
gen_build_spec_table.add_column("Details", justify="left")
540-
gen_build_spec_table.add_column("Value", justify="left")
541-
for field, content in self.gen_build_spec.items():
542-
gen_build_spec_table.add_row(field, content)
543-
self.gen_build_spec_table = gen_build_spec_table
541+
self.gen_build_spec_table = self._make_table(self.gen_build_spec, ["Details", "Value"])
542+
543+
def mark_failed(self) -> None:
544+
"""Convert any Processing Status entries to Failed."""
545+
for key, value in self.description_table_content.items():
546+
if isinstance(value, Status):
547+
self.description_table_content[key] = "[red]Failed[/red]"
548+
549+
self.description_table = self._make_table(self.description_table_content, ["Details", "Value"])
550+
551+
for key, value in self.find_source_content.items():
552+
if isinstance(value, Status):
553+
self.find_source_content[key] = "[red]Failed[/red]"
554+
555+
self.find_source_table = self._make_table(self.find_source_content, ["Details", "Value"])
556+
557+
for key, value in self.gen_build_spec.items():
558+
if isinstance(value, Status):
559+
self.gen_build_spec[key] = "[red]Failed[/red]"
560+
561+
self.gen_build_spec_table = self._make_table(self.gen_build_spec, ["Details", "Value"])
562+
563+
if self.if_dependency and self.dependency_analysis_list:
564+
for dependency in self.dependency_analysis_list:
565+
dependency.mark_failed()
544566

545567
def make_layout(self) -> Group:
546568
"""

0 commit comments

Comments
 (0)