Skip to content

Commit

Permalink
Do not use term.formatter()
Browse files Browse the repository at this point in the history
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 <module>
      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'
  • Loading branch information
dlax committed Nov 30, 2020
1 parent 6234810 commit 28e46e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pgactivity/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))}"
Expand Down
2 changes: 1 addition & 1 deletion pgactivity/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("│")]),
Expand Down

0 comments on commit 28e46e3

Please sign in to comment.