From ae169fa9f5a54857d3d8d4d20c9cab97c7daf986 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 26 Mar 2025 10:36:25 +0100 Subject: [PATCH] return code colouring --- examples/tail.toml | 7 ++----- foucault/gui.py | 8 +++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/tail.toml b/examples/tail.toml index 3bd5609..43719cb 100644 --- a/examples/tail.toml +++ b/examples/tail.toml @@ -12,17 +12,14 @@ selected = [] [[arguments]] name = "name" -enabled = true +enabled = false inline = true boolean = false options = [ - "gui.py", "nonexistent.py", - "test", - "meer", ] selected = [ - "gui.py", + "nonexistent.py", ] [environment] diff --git a/foucault/gui.py b/foucault/gui.py index d424503..79aaad8 100644 --- a/foucault/gui.py +++ b/foucault/gui.py @@ -289,10 +289,12 @@ class SubprocessUI: @ui.refreshable_method def ui(self): - card_class = "bg-teal" if self.sc.is_running() else ("bg-warning" if self.sc.return_code() and math.abs(self.sc.return_code()) != 15 else "bg-gray") + exit_code = self.sc.return_code() + erroneous_exit = exit_code and abs(exit_code) != 15 + card_class = "bg-teal" if self.sc.is_running() else ("bg-warning" if erroneous_exit else "bg-gray") with ui.card().classes(card_class): with ui.row(align_items="stretch").classes('w-full'): - if self.sc.return_code(): + if erroneous_exit: ui.label(f'⚠').classes('text-h5') ui.label(f'{self.sc.name}').tooltip(str(self.sc.filename)).classes('text-h5') @@ -303,7 +305,7 @@ class SubprocessUI: ui.button('↺', on_click=self.sc.restart, color='red' if self.sc.is_stale() else "primary") - ui.label(f'Running: {self.sc.is_running()}' + f"({self.sc.return_code()})") + ui.label(f'Running: {self.sc.is_running()}' + (f" ({self.sc.return_code()})" if self.sc.return_code() is not None else "")) ui.code(f'{" ".join(self.sc.cmd)}') ui.code(self.sc.as_bash_string()) ui.separator()