return code colouring

This commit is contained in:
Ruben van de Ven 2025-03-26 10:36:25 +01:00
parent 7ca69fdb24
commit ae169fa9f5
2 changed files with 7 additions and 8 deletions

View file

@ -12,17 +12,14 @@ selected = []
[[arguments]] [[arguments]]
name = "name" name = "name"
enabled = true enabled = false
inline = true inline = true
boolean = false boolean = false
options = [ options = [
"gui.py",
"nonexistent.py", "nonexistent.py",
"test",
"meer",
] ]
selected = [ selected = [
"gui.py", "nonexistent.py",
] ]
[environment] [environment]

View file

@ -289,10 +289,12 @@ class SubprocessUI:
@ui.refreshable_method @ui.refreshable_method
def ui(self): 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.card().classes(card_class):
with ui.row(align_items="stretch").classes('w-full'): 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'').classes('text-h5')
ui.label(f'{self.sc.name}').tooltip(str(self.sc.filename)).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.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(f'{" ".join(self.sc.cmd)}')
ui.code(self.sc.as_bash_string()) ui.code(self.sc.as_bash_string())
ui.separator() ui.separator()