From 28e46e339f9b905f61b5e167c9aaf3245e25984a Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Mon, 30 Nov 2020 14:31:49 +0100 Subject: [PATCH] Do not use term.formatter() This does not work with blessed from Debian/buster: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/blessed/formatters.py", line 82, in __call__ attr = curses.tparm(self.encode('latin1'), *args).decode('latin1') TypeError: an integer is required (got type str) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/pg_activity", line 260, in ui.main(options) File "/usr/lib/python3/dist-packages/pgactivity/ui.py", line 113, in main width=width, File "/usr/lib/python3/dist-packages/pgactivity/widgets.py", line 15, in boxed border_formatter = term.formatter(border_color) File "/usr/lib/python3/dist-packages/blessed/formatters.py", line 92, in __call__ self._name, args, err)) TypeError: A native or nonexistent capability template, 'formatter' received invalid argument ('yellow',): an integer is required (got type str). You probably misspelled a formatting call like `bright_red' --- pgactivity/ui.py | 2 +- pgactivity/widgets.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pgactivity/ui.py b/pgactivity/ui.py index 0e7e822a..c34fef90 100644 --- a/pgactivity/ui.py +++ b/pgactivity/ui.py @@ -97,7 +97,7 @@ def main( keys.PROCESS_CANCEL: ("cancel", "yellow"), keys.PROCESS_KILL: ("terminate", "red"), }[key] - action_formatter = term.formatter(color) + action_formatter = getattr(term, color) pids = pg_procs.selected if len(pids) > 1: ptitle = f"processes {', '.join((str(p) for p in pids))}" diff --git a/pgactivity/widgets.py b/pgactivity/widgets.py index 219ea3ab..586bd394 100644 --- a/pgactivity/widgets.py +++ b/pgactivity/widgets.py @@ -12,7 +12,7 @@ def boxed( width: Optional[int] = None, ) -> str: border_width = term.length(content) + 2 - border_formatter = term.formatter(border_color) + border_formatter = getattr(term, border_color) lines = [ border_formatter("┌" + "─" * border_width + "┐"), " ".join([border_formatter("│") + term.normal, content, border_formatter("│")]),